samjarman Posted July 6, 2014 Share Posted July 6, 2014 Hi, I'm trying to create a play, pause button on my game so people can stop and start the game. Here's what I have so far //load in textures//set up buttonthis.playPauseButton = levelData.game.add.button(570, 430, 'pause', pausePlayPressed, this, 2, 1, 0);//click functionfunction pausePlayPressed(){ if (levelData.game.isRunning){ levelData.game.paused = true; this.playPauseButton.loadTexture('play'); } else { levelData.game.paused = false; this.playPauseButton.loadTexture('pause'); }}but, when I pause the game, I cant seem to re-click the button to resume the game. I accept this might be intended behaviour, but surely theres a way around this...? :S CheersSam Link to comment Share on other sites More sharing options...
Nambiar Posted July 6, 2014 Share Posted July 6, 2014 game.paused = true stops all input listeners too so your buttons would not work. What you can do is add an input event to the game itself by game.input.onDown.add(function, this) and then check whether the clicks happen on the pause menu buttons . More on this http://www.html5gamedevs.com/topic/4684-any-pause-screen-code-examples/ http://examples.phaser.io/_site/view_full.html?d=misc&f=pause+menu.js&t=pause%20menu samjarman 1 Link to comment Share on other sites More sharing options...
delueg Posted July 6, 2014 Share Posted July 6, 2014 1. You can do an domelement outside the game and add the event to it. this would work, but sometimes you don´t want any dom elements, so.. 2. my suggestion is, that you create a pause variable and handle your pause by yourself. i relied on the integrated pause mode and had to do it by my own afterwards. Link to comment Share on other sites More sharing options...
Recommended Posts