Jump to content

Issue with setting velocity of sprites back to 0 each update


oom1993
 Share

Recommended Posts

Hi, 

I am currently facing an issue where I am trying to replicate a sprite stopping after each update. Just like in this example https://phaser.io/examples/v2/input/keyboard-justpressed 

I'm using similar input and velocity changes to the example aswell.

However when I add these two lines of code at the start of update().

sprite.body.velocity.x = 0;
sprite.body.velocity.y = 0;

None of my sprites are visible on the screen. I have tried commenting out most code that could possibly affect this with no luck. I am using phaser 2.6.2.

Without those two lines of code, my program works as normal but the sprites continue to move.

I also tried the below line but had no luck.

sprite.body.velocity.setTo(0, 0)

Has anyone experienced a similar problem or is there an alternative to stopping a sprite in each update call?

Many thanks

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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