1 decade ago by fulvio
I have the following entity, however when I set
Is there a way to set the
this.showText to true the font appears behind the entity.Is there a way to set the
zIndex for fonts that are drawn?
ig.module('game.entities.large-computer').requires('impact.entity').defines(function() {
EntityLargeComputer = ig.Entity.extend({
size: {
x: 80,
y: 68
},
zIndex: -1,
msg: '',
duration: 0.1,
playedSound: false,
gravityFactor: 0,
animSheet: new ig.AnimationSheet('media/sprites/large-computer.png', 80, 68),
sfxComputer: new ig.Sound('media/sounds/computer.*'),
font: new ig.Font('media/fonts/font.computer.png'),
showText: false,
init: function(x, y, settings) {
this.parent(x, y, settings);
// Specify which icon to use.
this.addAnim('idle', 0.2, [0]);
this.addAnim('active', 0.2, [0]);
this.idleTimer = new ig.Timer();
},
ready: function() {
// Make sign entity invisible in-game.
// delete this.currentAnim;
},
update: function() {
var distanceTo = this.distanceTo(ig.game.player);
if (distanceTo <= this.size.x * 2) {
this.currentAnim = this.anims.active;
this.showText = true;
// Play computer sound.
if (!this.playedSound) {
this.sfxComputer.play();
this.playedSound = true;
}
} else {
this.currentAnim = this.anims.idle;
this.playedSound = false;
this.showText = false;
}
// Call parent.
this.parent();
},
draw: function() {
if (this.showText) {
this.font.draw(this.msg, this.pos.x, this.pos.y, ig.Font.ALIGN.CENTER);
}
this.parent();
}
});
})
