Game Development Reference
In-Depth Information
(this.enemySprite.getBounds().width / 2);
this.magicSprite.y = 100;
this.magicSprite.scaleX = this.magicSprite.scaleY = .2;
this.addChild(this.magicSprite);
createjs.Tween.get(this.magicSprite).to({scaleX:1, scaleY:1}, 1000,
createjs.Ease.elasticOut);
return data.GameData.attackPower.lightning + weakness;
}
First, a check on the enemy data's weakness property will determine if the magic used should add any extra
damage. This value will simply be 5 across all enemies. Next, each function uses the magicSprite property to create
that special effect by using the appropriate frame from the sprite sheet. Each magic function uses a chain of tween
commands to create something cool over the enemy sprite. Figure 14-8 shows a minotaur being attacked by fire.
Figure 14-8. An enemy being attacked by fire
The function will also ultimately return the final damage value caused by the magic. The total magic damage is
determined by referencing the attackPower object in GameData and adding it to any weakness that may have been
applied. This returned value will be factored at the end of the takeDamage method and passed into the enemy health
bar, which is recapped here:
damage = damage > 0 ? damage : 0;
this.healthBar.updateHP(damage);
Search WWH ::




Custom Search