wisniewski94/sprites.js

How to play the animation in reverse

Closed this issue · 1 comments

Is there an option to play the animation in reverse something like

animation.play({ from: 5, reverse: true });

Sure, when you use .play() method you should specify start and ending frame like so:

Code below will loop forwards from frame 1 to 8.

parrot.play({
    fps: 5,
    from: 1,
    to: 8,
    n: 0,
    step: function(e) {
      console.log("step:", e);
    },
    loop: function(e) {
      console.log("loop:", e);
    }
  });

Meanwhile this will loop backwards from 5th frame to 1st:

parrot.play({
    fps: 5,
    from: 5,
    to: 1,
...})