Well, i’ve googled it and had quite a time figuring out how to.
I’ve got idle-animation with all the frames with frameHeight 54, so on the init hero.body is 54 high.
Next I’ve got an attack-animation with frames of different heights. It starts with frameHeight 70, next frameHeight 64, next 68 and so on. It ends with frameHeight 68.
If i do
update() {
-
this.player.body.setSize(this.player.frame.width, this.player.frame.height, true);*
}
then at the end of attack-anim, when anims transit to “idle” state I get a hero’s body at (68-54)/2= 7px up high from earth and the body falls down 7px
If I make body.setOffset - it works well only for the first sprites with frameHeight 70, next attack-anim frames with different frameHeight look poor.
By now the only solution I can see is to make all the frames in one particular animation the same frameHeight. And it is so very long because basically all of my sprites have slightly different frameHeight.
Please give me an idea how to code a lot of different sized sprites in one animation into a good looking animation and animation-transition. Or give me a hint how to automatize the process of bringing all the sprites to an equal frameHeight.