I am developing a game with cocos2d. Naturally, I have a menu button.If it's clicked , there will be "void" called , where I stop all current actions with [[CCDirector sharedDirector] pause];
and introduce a menu.
Also, I have sprites that are stopped and have instructions if they are touched (just some MoveTo actions). When I click on sprites during pause there appears a mistake(as I think, because of that instruction).
So, I assume, that sprites should be untouchable during game pause. How can I make a single sprite untouchable? Are there better ways to avoid such a mistake?
Once you use [[CCDirector sharedDirector] pause]; then your complete cocos2d is paused. So if you have written some cocos2d actions inside the touch callback or written something to do like move sprite etc on touch then you will encounter a crash. Instead try to stop all actions and schedulers on the scene and proceed further. You can stop all actions and schedulers as below:
[self pauseSchedulerAndActions];//This will pause all the scheduler and actions running on current scene. Note this will not unschedule the update().
To stop the update method as well do-
[self unscheduleUpdate]; //This will stop the cocos2d update method
Once you paused this way now you can perform any action on the sprite and once done then you can resume as below:
[self resumeSchedulerAndActions];
[self scheduleUpdate];