cocos2D deallocing CCScheduler

2019-09-11 05:19发布

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?

2条回答
Bombasti
2楼-- · 2019-09-11 05:33

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

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

查看更多
Anthone
3楼-- · 2019-09-11 05:54

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.

查看更多
登录 后发表回答