I'm developing an Android game with all the typical stuff it envolves: the game loop, renderer, panel, ...
The problem is that when I exit the game, it always crashes... I think it's because I don't stop correctly the game loop and it continues. Also, I would like to pause it when I "minimize" the game or I switch the mobile phone to stand by.
What should I put in onPause and onDestroy?
I only have this:
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
super.surfaceDestroyed(holder);
//Stop game loop:
loop.setRunning(false);
boolean retry = true;
while (retry)
{
try
{
//gameLoop.join();
loop.stop();
retry = false;
}
catch (Exception e)
{
// try again shutting down the thread
}
}
}
But it is not enough and it is only for exiting.
Thanks!!