The Settings Class

As with the Assets class, you can again reuse what you wrote for the previous games, to some extent. You can now store an additional Boolean that tells you whether the user wants to use the touchscreen or the accelerometer for moving the ship. You can drop the high-score support, as you don't need to keep track of this. As an exercise, you can, of course, reintroduce both the high-score screen and the saving of these scores to the SD card. Listing 12–2 shows you the code.

Listing 12–2. Settings.java, Same Old, Same Old

package com.badlogic.androidgames.droidinvaders; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; ...

Get Beginning Android 4 Games Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.