Game Development Reference
In-Depth Information
Figure 6-2.
The main menu screen. The coordinates specify where we'll render the different images, and the outlines
show the touch areas.
The x coordinates of the logo and main menu option images are calculated so that they are
centered on the x axis.
Next, let's implement the
Screen
. Listing 6-5 shows the code.
Listing 6-5. MainMenuScreen.java; the Main Menu Screen
package
com.badlogic.androidgames.mrnom;
import
java.util.List;
import
com.badlogic.androidgames.framework.Game;
import
com.badlogic.androidgames.framework.Graphics;
import
com.badlogic.androidgames.framework.Input.TouchEvent;
import
com.badlogic.androidgames.framework.Screen;
public class
MainMenuScreen
extends
Screen {
public
MainMenuScreen(Game game) {
super
(game);
}
We let the class derive from
Screen
again and implement an adequate constructor for it.
public void
update(
float
deltaTime) {
Graphics g = game.getGraphics();
List < TouchEvent > touchEvents = game.getInput().getTouchEvents();
game.getInput().getKeyEvents();