Jump to content

How to stop Player movement completely for a few seconds


Gamma
 Share

Recommended Posts

I would like it so that when a certain event happens, the player completely stops moving (for a few seconds or so), the user does not have the ability to move at all, and I am then able to proceed to call a function (which calls a function to end the game). How would I implement this? 

 

Here is a snippet of code located in my Update function:

(Please note: I am using the Phaser basic template, so when calling functions and methods, we must use 'this'. 

        if (this.game.physics.collide(player, certainItem)) {            var hit = this.game.add.audio('hit');            hit.play();            certainItem.kill();            player.body.velocity.x = 0; // Tried to stop, but I am still able to move him            player.animations.play('hit'); // Changes to the frame I wanted but then quick            //-ly changes back            //            this.gameOver();        }

Thank you in advance. 

Link to comment
Share on other sites

  • 3 weeks later...
 Share

  • Recently Browsing   0 members

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