Code the GameEngine

Now we get to the class that glues all the others together. In the code that follows we will declare and use an instance of LevelManager that we will code immediately after GameEngine. All the rest of the code will at last be error free and nearly ready to execute.

Add the GameEngine class, its members and constructor as shown next.

import android.content.Context; import android.graphics.Point; import android.util.Log; import android.view.MotionEvent; import android.view.SurfaceView; import java.util.concurrent.CopyOnWriteArrayList; class GameEngine extends SurfaceView implements Runnable, GameEngineBroadcaster, EngineController { private Thread mThread = null; private long mFPS; private GameState mGameState; UIController mUIController; ...

Get Learning Java by Building Android Games - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.