Game Development Reference
In-Depth Information
Listing 14-12. Enemy.js - Enabling and Disabling the Targets on Enemies
p.enableTarget = function () {
this.targetTween.setPaused(false);
this.targetable = this.targetSprite.visible
= this.mouseEnabled = true;
}
p.disableTarget = function () {
this.targetTween.setPaused(true);
this.targetable = this.targetSprite.visible
= this.mouseEnabled = false;
}
The enableTarget method will start the pulsing effect on the target sprite and show it. It will also set
the targetable property to true and enable mouse interaction so that the player can click it. After an attack, the
disableTarget method is called and does the exact opposite. An enemy in its targetable state is shown in Figure 14-7 .
Figure 14-7. The target indicator sprite is shown when an enemy can be attacked
Next, the functionality is written that will react to the enemy being attacked (see Listing 14-13).
 
Search WWH ::




Custom Search