Game Development Reference
In-Depth Information
boss.on('click', this.attackEnemy, this);
this.enemies[0] = boss;
this.enemyHolder.addChild(boss);
}
As you can see, the main difference when creating a boss is that there is only one enemy, so there is no need
for a loop, and the key for the enemy type is located in the
boss
property in the level's data. The boss' location uses
the
bossPos
class property, and the same
click
event is added as would have been with a regular enemy. It is then
pushed to the
enemies
array and added to
enemyContainer
. Figure
14-12
shows the boss in battle.
Figure 14-12.
The boss level
There is one remaining initializing method,
addBattlePanel
. The battle panel handles all player actions and is
contained within its own class. This class will be built now.