Gamma Posted February 15, 2014 Share Posted February 15, 2014 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 More sharing options...
Gamma Posted February 17, 2014 Author Share Posted February 17, 2014 Figured it out. The post may be closed. Link to comment Share on other sites More sharing options...
Mariusz Posted February 17, 2014 Share Posted February 17, 2014 Glad you figured it out, though to not make this thread completely redundant and a waste of space, perhaps you could post your solution as well? luschn 1 Link to comment Share on other sites More sharing options...
Gamma Posted March 5, 2014 Author Share Posted March 5, 2014 Glad you figured it out, though to not make this thread completely redundant and a waste of space, perhaps you could post your solution as well?player.body.velocity.x = 0; Link to comment Share on other sites More sharing options...
Heppell08 Posted March 5, 2014 Share Posted March 5, 2014 Might also be worth noting to stop the player from pressing a key when he is stopped you could add:this.input.disabled = true;Then make it false when the input is allowed again Link to comment Share on other sites More sharing options...
Recommended Posts