MrNom Game The Main Activity

Our application needs a main entry point, also known as default Activity on Android. We will call this default Activity MrNomGame and let it derive from AndroidGame, the class we implemented in Chapter 5 to run our game. It will be responsible for creating and running our first screen later on. Listing 6-1 shows you our MrNomGame class.

Listing 6-1. MrNomGame.java, Our Main Activity/Game Hybrid package com.badlogic.androidgames.mrnom;

import com.badlogic.androidgames.framework.Screen;

import com.badlogic.androidgames.framework.impl.AndroidGame;

public class MrNomGame extends AndroidGame { @Override public Screen getStartScreen() { return new LoadingScreen(this);

All we need to do is derive from AndroidGame and implement the getStartScreen() method, which will return an instance of the LoadingScreen class (which we'll implement in a minute). Remember, this will get us started with all the things we need for our game, from setting up the different modules for audio, graphics, input, and file I/O to starting the main loop thread. Pretty easy, huh?

0 0

Post a comment