Search the Community

Showing results for tags 'pause'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 35 results

  1. I want to run myPixi.ticker.stop() when the window loses focus in any way, eg minimize, click a different tab or even closing the window. Q: Is there a javascript event that covers all the possibilities? Q2: Is there a javascript event that covers all possible methods of a window regaining focus, eg a return from minimize, reclicking the tab etc?
  2. Any Pause Screen Code / Examples?

    Hi guys – just discovered Phaser yesterday. Just wondering if anyone has an example of a pause screen/state in a game created? Would be great to see some code. Had a look at the examples in the docs and couldn't see anything. Also, is the only way to pause/resume a game to individually pause and then resume all the moving / relevant elements, or am I missing some amazing game.pause() function? I pretty familiar with JS, but am pretty much a noob at creating games with frameworks. Many thanks, Shaun
  3. How would pause ALL playing sounds... I am trying to make a pause (start/stop) functionality especially for in-game menu... Since i control the render loop and is NON-Anoymous function so can easy stop using the function that was started with... Works great but i need to PAUSE the sound too... How???
  4. here I found example: but there sholud use game.input.onDown.add (this is little uncomfortable, there should to plot the field x y buttons positions...), I noticed that it depends on the game.paused - if game.paused=true; these any buttons not warking correctly... If I would like use clissic buttons - game.add.button(positionx, positiony, 'button', function(){ }); I must used other idea to paused? I would like to create a more interactive menu (sliders, hover animations, cursor pointer), it is recommended that other solutions to this prolblem? Or maybe better create this menu in html/css? how to do it correct? Thanks for answer
  5. Hi everyone, i was trying to pause a scene when the browser window is not active(eg. user switches tab, ctrl/cmd+tab, another window is currently focus,etc). To pause the scene, i need the background music and all animations to be paused, below playground example shows my approach: I got two results: 1. when I click on another window(for example a notepad) that overlapped the browser, the notepad is now focus and the browser is blur, hence both sound and animation are paused, this is expected; 2. when I ctrl/cmd+tab or manually click on another tab to switch tab, only sound is paused but the animation continues playing. looks like $(window).blur(function() {...}); is triggered, but only bgm.pause() work, anim.pause() doesn't work. $(window).focus(function() { anim.restart();; }); $(window).blur(function() { anim.pause(); bgm.pause(); }); any help will be appreciated, thank you!
  6. So I have 2 animations that both work independently. I can pause and unpause either of them fine but I can't pause one, play the other and then unpause the first. This doesn't and no animations play in the end Any ideas?
  7. Active buttons while game is paused

    Can anyone help me on creating a button that is active even if the game is on pause (game.paused = true;)?
  8. Pause and Sound resume issue

    Hi, I'm really new to phaser and having some issues with my game on which I created a script that when the player clicks or goes outside of the game (e.g. clicks another tab), the music should be paused and when it resumes (user clicks back in game), music should continue. The issue is that when the game continues, it music starts over the very beginning. I've followed some of the examples that I've found here but still does not work. Anyone experiencing the same thing or it's juts with my implementation? var introState = function(game){ }; introState.prototype = { preload: function(){'intro', '../music/intro.mp3'); }, create: function(){ recording ='intro');; game.onPause.add(pauseMusic, this); game.onResume.add(resumeMusic, this); }, render: function(){ } } function pauseMusic() { recording.pause(); } function resumeMusic() { recording.resume(); } This is just one of a state with in my game. Any help is appreciated. Thanks
  9. Pause Button

    I am creating an HTML, JS ,CSS game for android. Can someone write an example for a pause button. PS:I have a timer and it need to be stoped when button is presst.
  10. Hi! In my game you can play with a keyboard and a gamepad. With keyboard I can pause the game and execute other actions, for example can I unpause the game. However with the gamepad the player can pause the game but can not execute actions buttons gamepad with the game on pause. //pause this.actionControls.pauseKey.onDown.add(utils.pauseMenu, this); this.actionControls.pausePad.onDown.add(utils.pauseMenu, this); //utils.pauseMenu unpause the game if the game on pause Any help? A greeting!
  11. I wrote a simple function to pause rendering. window.addEventListener('blur',function(){ _ENGINE.stopRenderLoop() console.log('paused'); }); window.addEventListener('focus',function(){ _ENGINE.runRenderLoop(function(){ _SCENE.render(); }) console.log('resumed') }); When the playground code is running, i tried to pause the game by clicking the outside elements of my web browser (you can click on the console log, or the URL tab to activate the pause). The funny thing is, when I click on the scene to resume the rendering, the cube has already travelled a lot. It's as it the computations for the cube (its animations) wasn't paused. Playground link: Any ideas?
  12. I have on an extended Phaser.Game class the following let game = this; game.onGameStart = Phaser.Signal(); function startGame(){ game.onGameStart.dispatch(); } in an extended Phaser.State class I have the following create(){ let game =; game.onGameStart.add(this.start, this); game.message.on('message', function(){ game.startGame(); } // message is a node server web socket remote trigger response game.paused = true; } function start() { = false; } When game.startGame() gets called start its called but the game._paused and game._codePaused is still set to true. WHY is this?
  13. Pause game and Jquery functions

    I am currently working a a dialogue system, using DOM and Jquery to have a bit more flexibility. In short, I have an issue where I need to click two times my "close" button for the dialogue to disappear (the first one reloads the pause screen). Not sure if the problem comes from the way Phaser handles pause, an issue with Jquery, or just the way I wrote my code. A simplified version of the code would look like this: Darkness.GameState = { create: function() { ... }, update: function() { ... }, interactNpc: function(player, npc) { if (this.isActionPressed && BasicGame.gamePaused == false) { BasicGame.gamePaused = true; var game =; game.paused = true; $('#dialogues').one('click', '#close-dialogue', function() { BasicGame.gamePaused = false; game.paused = false; }); } }, }; The this.isActionPressed bit is set to true or false in the update function. InteractNpc is triggered when the player overlaps a npc and presses the action key. I wonder if my var game =; is not the culprit, but I don't know how to access the game object from inside the click function in another way...
  14. (Edit): Short version: As simple as the title sounds. How can you pause an animation and then resume it from that same frame? Long version: I am completely stumped with something I thought would be very simple. I have an animation that plays. When an event occurs (I don't know when it will happen ahead of time), the animation needs to pause on its current frame. Then, I need to be able to resume the animation from that frame. I have searched all around and can't seem to find a simple solution to this. Here's what I want to do (but this doesn't work): var player = game.add.spritesheet('hero', 'hero.png', 32, 32);player.animations.add('run', [0,1,2,3], 12, true);'run');// pause animation for a momentfunction freeze() { player.animations.currentAnim.pause();, function(){ player.animations.currentAnim.resume(); }, game);}Things I have already tried: Using stop() and play() - this just starts the animation from the beginningSetting currentAnim.paused = true - doesn't seem to have any effectUsing setFrame() and play() together - just plays from the beginning Any help would be greatly appreciated!
  15. How to start a game in a paused state?

    I would like to start my game in a paused state with simple instructions on the screen, such as "Arrow keys to navigate, Space bar to shoot". Once the user hits one of these keys, the text would disappear and the game would start. I'm clear on showing and hiding the text. Is there a simple technique for pausing the start of the game? Most of the examples I'm finding online are more involved than what I'm looking for.
  16. Phaser/Cordova Pause/onPause

    Hi, We are in the process of making an "app" version of the game via Cordova and I'm struggling to fix an issue in relation to the game pausing on iOS. We provide a link to an external webpage to allow the player to register for the game and this is opened via: '_system'); return false;If I call game.paused = true before, nothing happens and the game continues.If I call game.paused = true after, the link opens but I receive a gpus_ReturnNotPermittedKillClient error and crash. The thing is, this doesn't get called because the window starts opening there and then. I tried to circumvent this by putting the call in a setTimeout function (delayed by 1 second) but I get the same result. I am using 2.4.2 so the game.lockRender property should also be set to true but the same issue happens. If I try to do it directly the same results. Moreover, I've added a game.onPause signal receiver in the state this happens in but this never gets called. Which makes me believe that whatever should be happening as a result of game.paused isn't actually happening. Any ideas on how I can resolve this?
  17. How to pause arcade physics

    Just hoping there was a simple way to pause the arcade physics system for when I go into a pause menu... I don't see any property, method or "easy way" in the docs. If this doesn't exist, then what is the right way? Thanks
  18. Hi I'm trying to find a reliable way to calculate the time the game is being played and isn't paused. My scenario is that I want to show a "time left" counter on screen but I found out that isn't reliable as it's counting even if game.paused is true. thanks
  19. I have the following code in the Boot.js init: function () {, this);, this);},onGamePause: function() { console.log('onGamePause'); if (!MainGame.supportAudio) return; game.sound.mute = true;},onGameResume: function() { console.log('onGameResume'); if (!MainGame.supportAudio) return; game.sound.mute = false;}, then, I call "pause game" in the Game.js for example like that: pauseGame: function () { MainGame.isPaused = !MainGame.isPaused; game.paused = MainGame.isPaused; if(MainGame.isMusicMuted){ game.sound.setMute(); }else{ game.sound.unsetMute(); }} and then, when the browser/tab loss focus, onGamePause and onGameResume don't work. main goal: to continue to play music after calling pauseGame, it's done as you see, but if the browser/tab loss focus - mute music.
  20. Please bear with me, this is very likely going to be a long post. In my quest to implement a pause system with an active ui I found myself investigating input/Pointer.js. Here I discovered the reason that my Buttons were useless when the game was paused. Specifically: input/Pointer.js if ({ return this;}My first, and simplest fix for my use case, was simply to comment out all of the above lines. This allows me to still process Pointer callbacks when the game is paused. In my case, the UI is already set up using callbacks, but the rest of the game uses polling. So it was a convenient way to allow UI interaction without allowing other in game actions. Offhand this method seems to have some limitations. If you're implementing first person controls your character might still spin around while you interact with the UI, though I haven't looked into it. Also if you use Pointer callbacks on any objects you want to actually pause that can cause issues. After some more thought I came up with the following solutions: First: input/Pointer.js while (i-- && !{[i][i].context, this, this.x, this.y, fromClick);}All I did was add a check if the game was paused before running any moveCallbacks. Correct me if I'm wrong, but I believe this would solve the issues with a first person style camera. Honestly though I'm not sure what all uses there are for moveCallbacks so some examples for context would be nice. Next: input/Pointer.js else if (! || ( && candidateTarget.sprite.nopause && candidateTarget.sprite.nopause == true))This allows you to set a nopause member on any sprite. This allows you to specify exactly which objects you want to respond while the game is paused. I went ahead and added a nopause member to the sprite constructor as follows: gameobjects/Sprite.js this.nopause = false;Then I can clean up the checks from before: input/Pointer.js else if (! || ( && candidateTarget.sprite.nopause == true))What do you guys think?
  21. _tweens undefined on object

    I've been trying to extend the functionality of TweenManager, so it can resume and pause everything within a group. I adapted the code from here: When debugging with console, _tweens and _add are undefined for each object, so the function doesn't work. I think the code is correct? Any ideas why this isn't working? I'm guessing i've missed something crucial about _tweens. Here's the code: (This goes out to Rich and Lewster) Phaser.TweenManager.prototype.pauseAllFrom = function(obj, children) {console.log('pauseAllFrom', obj.type,, obj._tweens, obj._add); var o, c, t, len; if (Array.isArray(obj) ) { for (o = 0, len = obj.length; o < len; o++) { this.pauseFrom(obj[o]); } } else if ( (obj.type === Phaser.GROUP || obj.type==7) && children){ for (c = 0, len = obj.children.length; c < len; c++){ this.pauseFrom(obj.children[c]); } } else { for (t = 0, len = this._tweens.length; t < len; t++){ if (obj === this._tweens[t]._object){ console.log('pauseFrom _tweens:',this._tweens[t]); this._tweens[t].pause(); } } for (t = 0, len = this._add.length; t < len; t++){ if (obj === this._add[t]._object){ console.log('pauseFrom _add:',this._add[t]); this._add[t].pause(); } } }};Phaser.TweenManager.prototype.resumeAllFrom = function(obj, children) {console.log('resumeAllFrom', obj.type,, obj._tweens, obj._add); var o, c, t, len; if (Array.isArray(obj) ) { for (o = 0, len = obj.length; o < len; o++) { this.pauseFrom(obj[o]); } } else if ( (obj.type === Phaser.GROUP || obj.type==7) && children){ for (c = 0, len = obj.children.length; c < len; c++){ this.pauseFrom(obj.children[c]); } } else { for (t = 0, len = this._tweens.length; t < len; t++){ if (obj === this._tweens[t]._object){ this._tweens[t].resume(); } } for (t = 0, len = this._add.length; t < len; t++){ if (obj === this._add[t]._object){ this._add[t].resume(); } } }};I also had to add a condition for the object type, as the console wasn't recognising Phaser.GROUP, and spitting out a number for each object type. // from thiselse if (obj.type === Phaser.GROUP && children){// to thiselse if ( (obj.type === Phaser.GROUP || obj.type==7) && children){Any help would be greatly appreciated. Thanks
  22. phaser pause state

    helo. i tryed to make a pause screen. the problem is when i set = true, the whole game will be paused and i cant use animation and lots of function. my second try was a state over the lvl1 state and it could be work, but the new problem is: i only can pause the whole game and cant pause just a state. any idea? ty for advice
  23. When I create a repeating tween that yoyos with : var tween = game.add.tween(sprite).to({y: sprite.y+100}, 1000, Phaser.Easing.Linear.None, true, 0, 9999, true);it restarts beautifully when I leave the browser and return. But when I create a chained tween that loops, like : var tween = game.add.tween(sprite).to({y: sprite.y+100}, 1000, Phaser.Easing.Linear.None, true, 0, 0, false);{y: sprite.y}, move.time, Phaser.Easing.Linear.None, true, 0, 0, false);tween.loop();then the tween is stopped and doesn't always restart when I return to the browser (but sometimes it does, after a while!). Is there a reason for this, or is this a bug? Any way to make this work? UPDATE It seems the autostart of the second chained tween causes this behaviour. When I only set autostart on the first tween, the tween is being restarted when I return to the browser.
  24. Title Render gets called, but update doesn't.
  25. Pausing and Resuming Timer

    Quick question about using the timer and loop in Phaser. I'm trying to get a program that runs a timer that checks how long the user has been playing the game, with the time displayed and it needs to be able to pause when a menu is opened. This is what I have currently: function create() { timer = game.add.text(250, 150, '0'); this.currentTimer = new Phaser.Timer(game, false); this.currentTimer.loop(Phaser.Timer.SECOND, this.updateTimer, this); this.currentTimer.start();}function update() { if(pauseButton.isDown){ timer.setText('Pause'); this.currentTimer.pause(); } if(resumeButton.isDown){ this.currentTimer.resume(); timer.setText(counter); test++; }}function updateTimer() { counter++; timer.setText(counter);}Using the console log I can tell that the timer is starting correctly, and can be paused and then resumed. However, the text does not update except to Pause when I press pause. Anyone know a solution to this?