I am trying to have a character on my page that uses the Spritely script to animate. The sprite sheet that I am using contains a total of 92 frames. I would like for the animation to be clickable.
When clicking it for the first time, I want it to play up to frame 70 and stop. Then, the next time you click it, I would like for the animation to play from frames 70 to 92 and stop.
How should I write the code?
So far, I'm able to get the animation to play up to frame 70 and stop. Even as a beginner web developer, this was fairly easy.
Here's what I have so far:
$('#stacheguy2').click(function() {
$(this)
.sprite({fps: 30, no_of_frames: 92, play_frames: 70,})
});
With this code, when you click the character, it plays frame 1-70 and stops. That's good. However, the next time you click it, it picks up from frame 70 and continues for another 70 frames. How can I change this so that the animation only plays frames 70 to 92 on the second click?
PS: I would like to eventually have the character perform a different frame sequence for each click.
If you could help me with this I would be so grateful! Thanks!