我正在使用 andengine 开发游戏...我在游戏中覆盖了后退键..
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
//coding
gameBool=true;
new AlertDialog.Builder(this).setTitle("Warning!").setMessage(
"Are you sure you want to quit?").setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
//coding
//finish activity
}
}).setNegativeButton("Cancel", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//gameBool=false;
}
}).show();
break;
}
}
大约 5 秒后按下取消按钮时,只有更新方法才会被调用。它不会立即调用。请让我知道什么问题以及如何解决这个问题?. 游戏 apk 大小为 11mb 并加载许多图像.. 任何内存问题?
@Override
public void onUpdate(float pSecondsElapsed) {
if(!gameBool)
{
//Game code //Its working fine in game play .. but when press back key and cancel means. its calling after 5 sec only.. not immediately
}
}