Class: AnimationSheet animation frame index

86 views
Skip to first unread message

fanf1998

unread,
May 12, 2013, 6:37:04 PM5/12/13
to mel...@googlegroups.com
Hi,


When in the Class  AnimationSheet  when i set a animation like :

this.addAnimation("openDoor", [0,1,2,3]);

the animation ends when it passes through the frames 0,1,2,3 or 0,1,2,3,0?

because the frame 0 is repeated and only after that the animation ends

this.setCurrentAnimation("openDoor",   function(){ me.game.remove(this) });

I want that animation end on the 3 frame.

(Sorry my english)

Thanks to all,

Francisco



Jay Oster

unread,
May 13, 2013, 1:56:36 AM5/13/13
to mel...@googlegroups.com
Try this:
 
this.setCurrentAnimation("openDoor", (function () {
    this.setAnimationFrame(3);
    this.animationpause = true;
}).bind(this));

melonJS animation code uses index 0 to detect when an animation has ended, so you have to set the frame index then pause the animation if you want it to end on the final frame.

fanf1998

unread,
May 13, 2013, 6:48:38 AM5/13/13
to mel...@googlegroups.com
Thanks Jason worked perfectly.

The team melonjs have helped me a lot, you are awesome.
I'm working on a game and expect finish at the end of this month, when i have more news  I'll post  here.

Obrigado,
Francisco
Reply all
Reply to author
Forward
0 new messages