Saturday, January 25, 2014

android game development - Pause problem


            
Recently put forward a complete set, to be a flight shooting game, I set up a game button to pause the game, but found that after I pressed the pause, the game can be paused, but found that the canvas has been in shock, as if still kept painting, Repeat two. The pause button are constantly flashing, what the solution, the following are some of my code:
case GAME_PAUSE:
gamePause.draw (canvas, paint, gameState);
break;
case GAME_WIN:
canvas.drawBitmap (bmpGameWin, 0, 0, paint);
break;
case GAME_LOST:
canvas.drawBitmap (bmpGameLost, 0, 0, paint);
break;
I used to control the switch, there is a gameState state, depending on the state to deal with. Also
The above picture is running, there is a small problem is that monsters come out from the side, the border color will be a monster, causing the entire screen is surrounded by other colors, very coordinated. . .
Great God can tell you how to realize the game is paused.

Reply:
After you pause the game thread, you can not go brush interface, that is no longer calling invalidate (), so it will not execute onDraw
Reply:
cited a floor ncepu307 reply:
your game thread after the pause, you can not go brush interface, that is no longer calling invalidate (), so onDraw will not run

This is surfaceView I do, and I ordered a pause after, gameState set GAME_PAUSE, then the next time the paintings draw () inside the switch case would not have to paint the other, only to draw pause screen. It stands to reason that this problem would not arise, just do not know why.
Reply:
cited a floor ncepu307 reply:
your game thread after the pause, you can not go brush interface, that is no longer calling invalidate (), so onDraw will not run

And I ordered a suspended game thread is not suspended, just draw something different.

No comments:

Post a Comment