1 decade ago by fulvio
I have some collectable entities in my game. Instead of just executing
The problem with what I have at the moment is that it gets killed before the animation is meant to occur. Do I need to put in a delay or is there some better code that does this?
This is what I have at the moment:
this.kill();
, which immediately kills the entity. I would like to display a different animating image that shows it being collected in its place and then kill it off.The problem with what I have at the moment is that it gets killed before the animation is meant to occur. Do I need to put in a delay or is there some better code that does this?
This is what I have at the moment:
ig.module('game.entities.invincibility').requires('impact.entity').defines(function () { EntityInvincibility = ig.Entity.extend({ size: { x: 32, y: 32 }, checkAgainst: ig.Entity.TYPE.A, animSheet: new ig.AnimationSheet('media/sprites/invincibility.png', 32, 32), sfx: new ig.Sound('media/sounds/collect.*'), gravityFactor: 0, init: function(x, y, settings) { this.addAnim('idle', 0.08, [0, 1, 2, 3, 4, 5, 6, 7]); this.parent(x, y, settings); }, check: function (other) { this.kill(); }, kill: function() { this.sfx.play(); var pickupSheet = new ig.AnimationSheet('media/sprites/invincibility_picked_up.png', 32, 32); var pickup = new ig.Animation(pickupSheet, 0.05, [0, 1, 2, 3, 4, 5, 6], true); pickup.update(); pickup.draw(this.pos.x, this.pos.y); this.currentAnim = pickup; this.parent(); }, update: function () { this.parent(); } }); });