Jump to content

change framerate of a sprite


Bapt
 Share

Recommended Posts

Hi, i'm new with Phaser and i have a problem. I can't figured out why i can't change the framerate of my animation.

My idea was simple, when my player's speed goes above some speed, i want his animation to go faster.

So for the moment in my update i have this : 

player.body.damping = 0.5;    if (player.body.velocity.x < -1 && player.body.velocity.x >-10) {        player.animations.play('right',1);    }    else if (player.body.velocity.x < -10) {        player.animations.play('right',50);    }    else {        player.animations.stop();        player.frame = 12;    }    cursors.right.onDown.add(move);    function move () {        player.body.thrust(10);    }     if (cursors.up.isDown) {        player.body.moveUp(50);    }    else if (cursors.down.isDown) {        player.body.moveDown(50);    }

I tried to stop the animation before doing the play but i don't know how to stop just once so it's stopped all the time.

Is there a way to achieve what i want ?

Link to comment
Share on other sites

That's exactly what i wanted to do, i saw the delay function but i didn't know how to pick the right animation, i just didn't see the getAnimation. Thank you for the help, now i just have to deal with the trhust thing who don't reset when the speed slow down, but this is another question and i will do some research through the documentation.

Thank you.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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