Jump to content

Full body rotation when jumping


seekpunk
 Share

Recommended Posts

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 me
function 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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...