1 decade ago by bitmapshades
I'm trying to have it so the combat text floats above an enemy target's on receiving damage but so far I'm only successful in centering the text in the viewport. It has to be an offset issue but I'm not sure how to do it when translating enemy positions relative to the camera centred on the player.
Has anyone coded a flexible approach to that would enable damage types to show up in different coloured text?
enemy.js
Has anyone coded a flexible approach to that would enable damage types to show up in different coloured text?
enemy.js
// Floating combat text
damageTimer: function(time){
this.dmgTimer = new ig.Timer(time);
// Center in the viewport - would be better if the position was above enemies head
this.dmgtext = {x: ig.system.width/2, y: ig.system.height/2};
},
// called from draw() function
damageText: function(value){
if(this.dmgTimer){
if(this.dmgTimer.delta() < 0){
ig.game.font.draw(value, this.dmgtext.x, this.dmgtext.y-=2);
}
}
},
receiveDamage: function(value){
this.parent(value);
this.damageTimer(1);
this.currentAnim = this.anims.hit;
ig.game.spawnEntity(EntityExplosion, this.pos.x, this.pos.y, {particles: 2, colorOffset: 0});
},
