Search the Community
Showing results for tags 'resume'.
-
tl;dr Pause, sleep, resume and wake make for a confusing api initially. Also a master pause (logic and audio) would be handy ( I might have missed this though.) After a longish break of game dev I wanted to take a look at Phaser 3. Loving it so far, (Phaser has come such a long way) but I find the pausing/resuming the entire game(logic, animation, sounds) a little confusing. I'm making a master Pause/Play switch. After game.loop.pause() didn't have the desired effect I've switched to game.loop.sleep and awake(). But I'm unsure if this is the intended use for them. Looking forward to the release of this bad boy, continue doing awesome work. Cheers
-
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
-
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?
- 3 replies
-
- animations
- pause
-
(and 1 more)
Tagged with:
-
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(){ game.load.audio('intro', '../music/intro.mp3'); }, create: function(){ recording = game.add.audio('intro'); recording.play(); 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
-
(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);player.animations.play('run');// pause animation for a momentfunction freeze() { player.animations.currentAnim.pause(); game.time.events.add(500, 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!
-
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: http://jsfiddle.net/lewster32/L3u3gp5k/ http://docs.phaser.io/TweenManager.js.html#sunlight-1-line-127 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.name, 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.name, 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
-
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?
-
I have been playing with Phaser and i have this, I'm new to java script and i don't know if the things I'm doing are the right ways to do them, so any feedback to improve my code would be nice Also When I resume the music using (pause the music pressing P, i will add a button later). music.resume(); the music starts over again, am I doing something wrong ? When I finish I would maybe do a post about my experience starting with Phaser so others could learn from my mistakes.