How to pause and resume the game?

I am developing a game for Android using a game engine. I want the pause and resume button on the game screen.

I implemented this with MenuScene and to pause the game I use

engine.stop();

But as soon as he stops the engine, he does not start any touch events or clicks.

How to start the engine again?

or what could be the best way to do the same?

+4
source share
3 answers

Well, although I am not a pro and I do not know, I can give some advice. First of all, stopping the engine is not the pause solution you are looking for. So instead you should do it manuelly, which I mean:

  • : yourPhysicsWorld.unregisterPhysicsConnector(), . (setVelocity(0,0))

  • : yourScene.unregisterUpdateHandler()

  • : , . , , , SQLite SharePreferences Google.

, , .

+4

, :

mScene.setIgnoreUpdate(true);
mScene.setChildScene(mPauseScene, false, true, true);

mScene - , mPauseScene - .

, , :

mScene.clearChildScene();
mScene.setIgnoreUpdate(false);

/, . , ​​. , .

+2

To pause a game:

GameScene.gameScene.setChildScene(pauseScreen, false, true, true); 

add these lines to your Screen.So game that your game will pause

Resume game:

 GameScene.gameScene.clearChildScene();
0
source

Source: https://habr.com/ru/post/1529403/


All Articles