Game Development Reference
In-Depth Information
//attacked by hero
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;
}
p.takeDamage = function (power, attackType) {
var damage = power - this.data.defense;
this.playAttackedAnimation();
switch (attackType) {
case 'fire':
damage += this.getFireDamage();
break;
case 'earth':
damage += this.getEarthDamage();
break;
case 'lightning':
damage += this.getLightningDamage();
break;
default:
damage += 0;
break;
}
damage = damage > 0 ? damage : 0;
this.healthBar.updateHP(damage);
}
p.playAttackedAnimation = function () {
var event;
var hit = this.enemySprite.clone();
hit.gotoAndStop(this.data.frame + '_hit');
this.addChild(hit);
createjs.Tween.get(hit)
.to({alpha:.3}, 100, createjs.Ease.bounceInOut)
.to({alpha:.6}, 100, createjs.Ease.bounceInOut)
.to({alpha:.2}, 200, createjs.Ease.bounceInOut)
.to({alpha:.3}, 100, createjs.Ease.bounceInOut)
.to({alpha:.6}, 100, createjs.Ease.bounceInOut)
.to({alpha:.2}, 200, createjs.Ease.bounceInOut)
.call(function (hit) {
this.removeChild(hit);
this.removeChild(this.magicSprite);
this.checkHealth();
}, [hit], this);
}
Search WWH ::




Custom Search