Spawning the aliens
Now that all the alien components, as well as AlienLaserSpawner
, are coded, we can put them all to work in the game. It will take three steps, as follows:
- Update
GameEngine
'sdeSpawnReSpawn
method to spawn some of each alien. - Update the
Level
class to add some aliens and alien lasers to theArrayList
of objects. - Update the
GameObjectFactory
class to handle instantiating the correct component classes (that we just coded) when the level class requests the various alienGameObject
instances be built.
Let's complete these steps now.
Updating the GameEngine class
Add this code to the end of the deSpawnReSpawn
method:
… for (int i = Level.FIRST_ALIEN;     i != Level.LAST_ALIEN + 1; i++) {         objects.get(i).spawn(objects           .get(Level.PLAYER_INDEX).getTransform()); }
This loops through the appropriate...