Home > Software engineering >  Doing tuixiangzi game, how to realize the pause and resume, please?
Doing tuixiangzi game, how to realize the pause and resume, please?

Time:10-11

Set the timer, don't know how to stop the timer also suspended together

CodePudding user response:

VC6 tuixiangzi game source code warehouse VC6 game source code http://download.csdn.net/detail/zhao4zhong1/3230945

CodePudding user response:

reference 1st floor zhao4zhong1 response:
tuixiangzi game VC6 source code warehouse's VC6 source http://download.csdn.net/detail/zhao4zhong1/3230945


Thank you, but I need the specific solution...

CodePudding user response:

KillTimer directly, and start again when the SetTimer again, specific parameters refer to MSDN

CodePudding user response:

Timer can't pause, however can KillTimer kill the timer, then continue, the SetTimer again to create a timer

CodePudding user response:

You can define a variable, such as:
Bool m_pause;
At the start of the game when set to true:
M_pause=false;
The SetTimer (... );
The OnTimer () :
if(! M_pause)
Process_my_task ();
In this way, at the time of suspension, it is ok to directly buy m_pause as true

Start again, need to the operation of the two parts:
1. Buy m_pause to true
2. Reset all the variables of game
3. Buy m_pause to false
Actually new a better approach is to define a variable, such as bool m_rest, set to false when start the game:
M_pause=false;
M_reset=false;
The SetTimer (... );
The OnTimer () :
If (m_reset)
{
Reset_all_things ();
M_reset=false;
}
if(! M_pause)
Process_my_task ();
When need to start again, you just need to:
M_reset=true;
We have to do is

CodePudding user response:

You at the beginning of your game frame processing function in the
Add a static variable determine whether suspended:
If it is true, direct return;
Otherwise, executive function,
  • Related