How to correctly pause and resume game

How to correctly pause and resume game
0.0 0



I try to implement a pause and a resume button in my game.

inside my game I create a CCMenu, with two CCMenuItemFont.

I initiate the game, and initiate my CCMenu, call cocos2d::CCDirector::sharedDirector()->resume(); and hide the resume button using setVisible(false).

When the pause button is pressed, I hide the pause button, show resume button and call cocos2d::CCDirector::sharedDirector()->pause();

But the problem is when I press the pause button, the FPS that was previous 30 go down to 4, this is normal?

There’s a better or different way to pause and resume a game?


It depends on how you set up your game. This is how I do it.

Since I use a different update method to update my game ( not using sheduleUpdate( ) but schedule( ) instead ) I can control whether the update should be done or not by using two ways: one is to have a boolean variable to track whether updating is allowed and the other is to unschedule the update whenever needed.


‘Lance Gray’, I think I understand the way you work, thanks for share

But I use the traditional schedule update with other schedules, I’ll try to think a way to use the unschedule to pause my game.

If more people can share knowledge, I’ll be very grateful