DudeshootMankill Posted March 16, 2015 Share Posted March 16, 2015 I'd like to implement a turning animation on my sidescroller. I use the player.scale.x = -1/1 to flip the sprite when turning left to right and vice versa. Anyone got an idea how to accomplish this? Link to comment Share on other sites More sharing options...
kieve Posted March 16, 2015 Share Posted March 16, 2015 Unfortunately, you can't do much in 2D, but you can animate the player.scale.x between -1 and 1. See this fiddle:https://jsfiddle.net/g0b5wftg/ Link to comment Share on other sites More sharing options...
DudeshootMankill Posted March 16, 2015 Author Share Posted March 16, 2015 I'll draw the turning animation myself, i was looking for something like "If player is facing right, and left is pressed, play animation" and vice versa. I'm sorry if this is infact really simple and i've just missed something. Link to comment Share on other sites More sharing options...
nkholski Posted March 16, 2015 Share Posted March 16, 2015 If you use acceleration instead of controlling velocity you could play a turning animation while body.velocity.x>0 and body.acceleration.x<0 and vice versa. This will give the effect you see in SMB etc, if that's what you are looking for. Link to comment Share on other sites More sharing options...
DudeshootMankill Posted March 16, 2015 Author Share Posted March 16, 2015 If you use acceleration instead of controlling velocity you could play a turning animation while body.velocity.x>0 and body.acceleration.x<0 and vice versa. This will give the effect you see in SMB etc, if that's what you are looking for. That is very much what i'm looking for. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts