Home > Software engineering >  How to implement in the program of MFC single text suspended by pressing a key, then press to contin
How to implement in the program of MFC single text suspended by pressing a key, then press to contin

Time:12-31

Write a small game, can't control pause and continue

CodePudding user response:

Personal advice, an enumeration type variable is added to the class sign the game state (such as leisure, initialization, and suspended, end), all around the operation of the remaining state machine operation

CodePudding user response:

CodePudding user response:

On the first floor is a very good method, what State do, such as defining a game State variable State, suspension State enumeration is State_Pause, in function of the head in front of the judge if (State==State_Pause) and then run the following content, otherwise the return, there is a relatively simple method is to use the pop-up dialog box (game suspension, a continue button below, program to continue running after users click on the continue button), while (1) infinite loop (out of) under certain conditions such as blocking function, don't understand to ask me

CodePudding user response:

Similar multi-threaded control, task allocation,
You can control the task and role distribution, don't have to do is give them tasks directly,

CodePudding user response:

In order to achieve this function first your game to organize all the relevant code into a thread
And then control the thread
Refer to http://blog.csdn.net/xianglitian/article/details/6729851

CodePudding user response:

Pause, stop within all tasks related to game play, threads, timer, etc., save the game all the object's state. Then rest, no longer refresh.
All continue, that is, to restore the state of an object, and then restart the task, refresh and interface.
  • Related