I am trying to decide what the best method is to call "level complete-screen" and "game over-screen" in my real-time android 2d game. Currently I am using game-states and only updating my game when its in gamestate==GAMEPLAY
, but this sometimes makes resetting some stuff awkward. Another method I have tried is calling a new activity during real-time using context, like this:
public void startMenu() {
final Context context = this.getContext();
((Activity) context).runOnUiThread(new Runnable() {
public void run() {
thread.setRunning(false);
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
// Context context = getContext();
Intent intent = new Intent("nielsen.happy.activities.MENU");
intent.putExtra("level", level);
((Activity) context).startActivity(intent);
}
});
This method calls another activity during real-time from a View-class. But it seems a bit clumsy and forced. Just want to know if there is a preferred way to call these screens in real-time games?