Is there a way to change the animSheet to another png of an entity after the entity has been loaded? I have some code that changes the picture referenced in the animSheet but the character doesn't update since I assume the beginning variables are only hit when the entity was made. Is there a way around this other than putting all animation graphics into one png?
what do you have in mind for your entity?
if you're making a shooter game with the player carrying different weapons, I suggest using different entities. (eg: entity1 holds shotgun animations, entity2 holds machinegun anims ). Helps in organizing your code too.
I tried the spawn new entity technique and got it to partially work. On mobile you can see a slight glitch so I was hoping to be able to just change the animSheet but I think the answer is you simply can't after the Entity is made :/
1 decade ago
by dominic
Just specify some of your anims with a different animation sheet. The
.animSheet
property for entities is just there for convenience so you can use
this.addAnim
instead of using the
ig.Animation
constructor.
E.g. in your entity's init():
init: function( x, y, settings ) {
this.parent( x, y, settings );
var sheet1 = new ig.AnimationSheet( 'sheet1.png', 16, 16 );
this.anims.animWithSheet1 = new ig.Animation( sheet1, 0.1, [0,1,2,3,2,1] );
var sheet2 = new ig.AnimationSheet( 'sheet2.png', 32, 64 );
this.anims.animWithSheet2 = new ig.Animation( sheet2, 0.2, [0,1,2] );
}
You can also overwrite an existing animation in the
this.anims
object at any time.
Thanks Dominic , works beautifully. May want to consider changing your name to the Wiz... just saying :p
1 decade ago
by 80bit
Quote from dominic
You can also overwrite an existing animation in the this.anims
object at any time.
Where would this overwriting take place? Sorry for my ignorance. :) Still learning!
Page 1 of 1
« first
« previous
next ›
last »