cocos2D deallocing CCScheduler

2019-09-11 05:38发布

问题:

This problem started happening when I subclassed CCSprite (Entity) to recieve touch input. When I'm going away from the main scene by pushing to another, I make all Entities remove their delegation from the shared CCTouchDispatcher (ie onExit()). And then reactivate when the main scene returns (onEnterTransistionFinished()).

Half of the times this works fine. However, the other times this happens:

cocos2d: deallocing <CCScheduler: 0x2323a0>

Which I find rather strange. Is it even plausible that the Touch Delegates are the cause of the problem? Or is it perhaps memory-related?

回答1:

Are you perhaps issuing [[CCScheduler sharedScheduler] release]? If so, don't do that.

The CCScheduler is a singleton. It should never deallocate by itself.



回答2:

If I remember correctly the problem originated from trying to register/unregister the same Entity to/from the TouchDispatcher twice (ie it didn't have time to unregister/register before I tried registering/unregistering it again).

I solved it by adding a little BOOL _didRegisterWithTouchDispatcher to avoid doing something like that.