0

I'm new to android and I'd like to develop simple game.

I have read about the Activity lifecycle on the official android site and also here on stackoverflow, but I need a little help with pausing/resuming the game :-/

I had expected some scenerio similar to the lifecycle diagram, but when I lock the screen, method Activity.onDestroy() is also called, but then onCreate() is called again. I am confused as onRestart() is not being called!

I know about the problem with screen orientation, and have added android:screenOrientation="landscape" which was supposed to help.

I'm happy with the other game mechanics such as animating, colisions etc, which are well described on the internet, but I can't manage pausing/resuming.

Could someone recommend a comprehensive tutorial or give a code example? Anything covering how to build the skeleton of simple game, which can be paused, saved, etc would be much appreciated.

thanks a lot

4

1 回答 1

0

尝试从调用游戏、surfaceView 或其他东西的活动中管理游戏线程......在线程中使用一些公共方法,暂停和恢复它们。在活动 onResume() 和 onPause() 中使用这些方法。也可以在暂停游戏时尝试停止线程,并在恢复时 - 创建一个新线程并启动它们。

于 2012-04-29T16:01:39.677 回答