1 decade ago
by dahl
So lets say I have a wall, the bad guys hit the wall, it gets damaged, the next time they attack it crumbles. all different anims. Is there a way to start a level with the wall entity set to a certain "state" animation wise? Or would it just be better to create 3 diff entities for starting off levels?
Thanks.
I do something like this to set a different animation to an entity on init.
EntityBlock = ig.Entity.extend({
size: {x: 16, y: 16},
type: ig.Entity.TYPE.NONE,
checkAgainst: ig.Entity.TYPE.NONE,
collides: ig.Entity.COLLIDES.FIXED,
animSheet: new ig.AnimationSheet( "media/tiles-faded.png", 16, 16 ),
blockType: "black",
init: function( x, y, settings ) {
this.parent( x, y, settings );
// Add the animations
this.addAnim( "black", 1, [7] );
this.addAnim( "red", 1, [8] );
// Switch animations on Init
this.currentAnim = this.anims[this.blockType];
},
});
Then when you spawn the entity you can do this:
ig.game.spawnEntity( EntityBlock, 0, 0, { blockType: "red" } )
It would spawn a block with the red animation.
Page 1 of 1
« first
« previous
next ›
last »