There is a Bug?

There is a Bug?
0.0 0


In the SpriteTest of tests, I cick right button, right button, right button, and left button. There is a assert of “assert(pSprite->getTexture()>getName == m_pobTextureAtlas>getTexture()->getName());”
why ?


Yes, I crashed too. But not crashed at assert.
#690 is created.


i tested it right now, and it crashed at the same place as cxb www.


When I comment “return new SpriteFrameAliasNameTest();”, there is ok! So I guess ,“grossini_dance_01.png” of resources has led to the problem!


OK, I know! The resources “animations/grossini.plist” and “animations/grossini-aliases.plist” both has “grossini_dance_01.png”. And In the constructor of SpriteFrameTest, there is load “grossini_dance_01.png”. In the destructor of SpriteFrameAliasNameTest, there is to do “removeSpriteFramesFromFile(”animations/grossini-aliases.plist“)”.
When I click left button, there calls “backSpriteTestAction”. In the backSpriteTestAction, first “createSpriteTestLayer(sceneIdx)”, second " pLayer->autorelease()“. And in the”createSpriteTestLayer(sceneIdx)“, the resources”animations/grossini-aliases.plist" don’t remove.!


Oh, when I test in the lastest code from git, it is not problem. Maybe some pull request resolve it.


I’ve hit this assert/crash from a couple of different things in my own code. It bothers me that it’s assuming the child is a sprite at all. Just now I hit it trying to add a label as a child of another label (Just experimenting with a simple hack to get drop shadows with my bitmap font). CCLabelBMFont does not derive from CCSprite at all, but this function assumes any child of a CCSpriteBatchNode, which CCLabelBMFont does inherit from, must be a CCSprite. So trying to add a CCLabelBMFont as a child of another CCLabelBMFont will crash here.

I’m guessing (when I should really be going to look so as to be more helpful) that the Obj-C version does a type check on the object to make sure it’s actually a sprite, and if not, just passes it on to CCNode’s addChild. In this version, assuming the CCNode it is passed can be typecast to a CCSprite when it really shouldn’t be causes undefined behavior at best, which is usually an instant crash.

Is there any kind of type checking available to CCObject or CCNode that could be used here to assert if the CCNode is not a sprite, rather than treating it as one and crashing?

I’m new to cocos2d in general, not just the C++ version, so take this with a grain of salt, maybe I really am only supposed to be adding other CCSprites as children of these things.

I’m not on the latest version either, though this function looks the same up to the assert.


Because some platform don’t support RTTI, so we can not do the type checking at run time.