getContentSize() width & height always returns zero

getContentSize() width & height always returns zero
0.0 0


CCNode* pNode = SceneReader::sharedSceneReader()->createNodeWithSceneFile(“character_selection.json”);

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.


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()


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… :slight_smile: )