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; // This ArrayList can be accessed from either thread private CopyOnWriteArrayList<InputObserver> inputObservers = new CopyOnWriteArrayList(); HUD...