How to get “smooth” animation with movement?

I’m creating my 4th game with Phaser, a platformer, and I’m using Matter physics. I’ve run into a problem I’ve never ran in to before. I want my animation to loop as long as I’m holding a key (so it looks like the player is running), and when the key is released, I want the animation to stop. How do I do this?

This demo should give you the general idea. You need to react to keypresses, etc.

http://labs.phaser.io/edit.html?src=src\animation\reverse%20animation.js

1 Like

I have since implemented this a different way. But thank you for that. That is an interesting way of using the yoyo attribute! Will be sure to try it in my code