1 decade ago by fulvio
Below you will see my wonderful laser beam:
The problem is that the condition to check for frame 0 or frame 1 is never reached. Basically those frames are when the laser is in its off state.
I&
ig.module('game.entities.laser-beam').requires('impact.entity').defines(function() { EntityLaserBeam = ig.Entity.extend({ size: { x: 16, y: 16 }, offset: { x: 0, y: 0 }, _wmIgnore: true, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.A, collides: ig.Entity.COLLIDES.NEVER, gravityFactor: 0, doorHeight: 1, lastTile: null, animSheet: new ig.AnimationSheet('media/sprites/laser-anim.png', 16, 16), canKill: null, init: function(x, y, settings) { this.parent(x, y, settings); this.animSheet = new ig.AnimationSheet('media/sprites/laser-anim.png', 16, this.doorHeight); this.size.y = this.doorHeight; this.addAnim('idle', 0.1, [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 1, 1, 1, 1]); }, check: function(other) { if (this.canKill) { other.receiveDamage(ig.game.player.maxHealth, this); } }, update: function() { if (this.currentAnim.frame == 0 || this.currentAnim.frame == 1) { this.canKill = false; } else { this.collides = ig.Entity.COLLIDES.PASSIVE; this.canKill = true; } this.currentAnim.update(); }, receiveDamage: function(amount, from) {} }); });
The problem is that the condition to check for frame 0 or frame 1 is never reached. Basically those frames are when the laser is in its off state.
I&
039;ve used #this.currentAnim.frame
checks before and never had a problem. Not sure what's so different about this particular entity.