高人,遇到问题了,在Cocostudio通过Json文件产生的Sprite怎么获取Size,怎么我获取的Size都是零,我如何做碰撞检测。
auto node = SceneReader::getInstance()->createNodeWithSceneFile(“Demomap/publish/RPGGame.json”);
if (node) {
this->addChild(node, 0);
}
auto hostCity = (node->getChildByTag(10004)->getChildByTag(10006)->getComponent("CCSprite")->getOwner());
auto vec = hostCity->getBoundingBox();
log("hostCity x %.2f y %.2f width %.2f height %.2f", hostCity->getPositionX(), hostCity->getPositionY(),
vec.size.width, vec.size.height);
这个时候的getBoundingBox和getContentSize都是0.