So far I could track down every error/crash I had in my cocos2dx application, but now I feel myself dumb. I have an array of CCSprite pointers, and what I want to do is to change it's display frame from the cache when the player has x score.
All the sprite frames are read from a plist file, and the sprite is there and working, because I can see it without any problem before trying to switch to the new frame. The "background.png" is a valid sprite frame name, since I'm using it to create the actual sprite which works.
This line works fine (or at least it seems to work)
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("background.png");
The problem is with this line:
for (int c = 0; c < sizeof(mBackground) / sizeof(CCSprite*); c++){
mBackground[c]->setDisplayFrame(frame);
}
This one also crashes:
CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("background.png");
mBackground[0]->setDisplayFrame(frame);
I ran out of ideas, I would really appreciate any help.
CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("background.png")Returns a null pointer. According to the documentation, it returns nil if the name is not found. The funny part is that I'm using the exact same name for creating the object. - LugaidVandroiy