seekpunk Posted December 26, 2014 Share Posted December 26, 2014 I am trying to make a full rotation when the player is jumping before hitting the ground something like this : `http://cd8ba0b44a15c10065fd-24461f391e20b7336331d5789078af53.r23.cf1.rackcdn.com/gamesalad.vanillaforums.com/editor/7k/ec9ef1hnurpi.gif`this is a sample i made but its messy i don't know how to make this behavior can anyone help mefunction CheckMovement() { p.body.velocity.x = 0; p.body.x += 2.5; if (cursors.up.isDown && p.body.onFloor()) { jumping = true; p.body.velocity.y = -280; RotatePlayer(p); } else { jumping = false; if (p.body.onFloor()) { p.rotation = 0; } } } var rotation = 90; var flip=1; function RotatePlayer(p) { p.angle +=flip*( rotation + 30); if (p.angle == 180) { rotation = 180; flip=-1; } }I know there is something missing but i am really stuck in it it's been 2 days :/ Link to comment Share on other sites More sharing options...
lewster32 Posted December 26, 2014 Share Posted December 26, 2014 Unless you want to get bogged down in maths I'd use a tween for both the jump and the spin, that way you have complete control over the timing and angles, like this example: http://jsfiddle.net/lewster32/rmzp44wh/ casarock 1 Link to comment Share on other sites More sharing options...
seekpunk Posted December 27, 2014 Author Share Posted December 27, 2014 wow!!! that's exactly what i was looking for man .thank you for this quick reply i really appreciate it Link to comment Share on other sites More sharing options...
seekpunk Posted December 27, 2014 Author Share Posted December 27, 2014 Though is there anyway to edit the jump width ? i.e: the distance of the player Link to comment Share on other sites More sharing options...
Recommended Posts