CCNode* pNode = SceneReader::sharedSceneReader()->createNodeWithSceneFile(“character_selection.json”);
this->addChild(pNode);
CCSprite* characterSprite = (CCSprite*)pNode->getChildByTag(10003);
CCLog(“width: %f, height: %f”,characterSprite->getContentSize().width, characterSprite->getContentSize().height);
when i tried to get the content size, always returns zero for width and height.
Try to debug and check the “characterSprite” is null or not.
characterSprite is not NULL, i can able to getPosition for x and y values, also able to make sprite visible or not.
pyy07
May 6, 2014, 8:46am
#4
i meet the same problem, i load ccbi file using lua and the the getContentSize() returns zero
local node = CCBReaderLoad(“xxx.ccbi”, proxy, nil)
local size = node:getContentSize()
cruzo82
September 25, 2014, 2:48pm
#5
Use this instead - works well:
scrollBg->boundingBox().size.width (or height)
Also, note that the output is a float, do not try to print it as decimal (as i did… )