Putting everything together
We just need to tie up a few loose ends and we will at last be able to run the game.
Updating GameEngine
Add an instance of the Level class to GameEngine.
...
HUD mHUD;
Renderer mRenderer;
ParticleSystem mParticleSystem;
PhysicsEngine mPhysicsEngine;
Level mLevel;
Initialize the instance of Level in the GameEngine constructor.
public GameEngine(Context context, Point size) {
super(context);
mUIController = new UIController(this, size);
mGameState = new GameState(this, context);
mSoundEngine = new SoundEngine(context);
mHUD = new HUD(size);
mRenderer = new Renderer(this);
mPhysicsEngine = new PhysicsEngine();
mParticleSystem = new ParticleSystem();
mParticleSystem.init(1000);
mLevel = new Level(context,
new PointF(size.x, size.y), this);
}Now we can add some code to the deSpawnRespawn method that we coded the signature for in chapter 18. Remember that this method is called by the GameState class when a new game is needed...