This bug is a weird one. It doesn’t show up in “release mode”, only “debug mode”. When it does show up, it’s makes programs crash bad.
I could say a lot about it, but I think it’s better to say: run the attached sample program using MSVC2008 (please compile it for debug mode first) and check out the bug in action. Although the sample program is a bit weird and doesn’t seem to make any sense, the full program certainly does and has the same problem.
In short it boils down to this:
When you add a custom node (like CCSprite, but anything based on CCNode should do), one that uses scheduleUpdate to update itself, keep a reference to it and replace the current scene + layer, the Cocos2d scheduler will somehow get lost with the objects that are valid and what objects are not. So it’s really the combination of scheduleUpdate and replaceScene that triggers the bug. It’s also got something to do with actions.
The crashing can be fixed by using a custom selector instead (see the attached source files), but the documentation tellls me not to do that.
Well, I’m hoping I’m not being too vague here. The attached program will explain everything. Just run the app, follow the instructions on the screen and enjoy the crash
CocosSchedulerBug.zip (594.6 KB)