Game Development Reference
In-Depth Information
@Override
public void
resume() {
}
@Override
public void
dispose() {
}
}
The rest of the class consists of boilerplate methods that don't do anything.
Texture
reloading
is done in the
AndroidInvaders
activity, so there isn't anything left to take care of in the
MainMenuScreen
.
The Settings Screen
The settings screen offers the player options to change the input method and an option to
enable or disable audio. We indicate these options with three different icons (see Figure
12-4
).
Touching either the hand icon or the tilted-device icon enables the respective input method. The
icon for the currently active input method will have a gold color. For the audio icon, we do the
same as in the previous games.
The choices of the user are reflected by setting the respective Boolean values in the
Settings
class. We also make sure these settings are instantly saved to the SD card each time one of
them changes, via a call to
Settings.save()
. Listing 12-5 shows the code.
Listing 12-5. SettingsScreen.java, the Settings Screen
package
com.badlogic.androidgames.androidinvaders;
import
java.util.List;
import
javax.microedition.khronos.opengles.GL10;
import
com.badlogic.androidgames.framework.Game;
import
com.badlogic.androidgames.framework.Input.TouchEvent;
import
com.badlogic.androidgames.framework.gl.Camera2D;
import
com.badlogic.androidgames.framework.gl.SpriteBatcher;
import
com.badlogic.androidgames.framework.impl.GLScreen;
import
com.badlogic.androidgames.framework.math.OverlapTester;
import
com.badlogic.androidgames.framework.math.Rectangle;
import
com.badlogic.androidgames.framework.math.Vector2;
public class
SettingsScreen
extends
GLScreen {
Camera2D guiCam;
SpriteBatcher batcher;
Vector2 touchPoint;
Rectangle touchBounds;
Rectangle accelBounds;
Rectangle soundBounds;
Rectangle backBounds;