Harissa Posted July 10, 2014 Share Posted July 10, 2014 Hello, I'm trying to animate particles while the game.paused is true.I've already managed to get tweens to animate when the game is paused by using (Typescript):pauseUpdate() { console.log("updating during pause"); this.game.tweens.update();}This works fine for tweens and you can see the function being called in the log window: But when I usepauseUpdate() { console.log("updating during pause"); this.game.tweens.update(); this.game.particles.update();}My particles pause with the game and don't start until the pause is over. I had a look at the code in the game update function as shown here: http://www.html5gamedevs.com/topic/3144-paused-problem/?hl=%2Bpaused+%2Bparticles#entry20378and it looks like I should be able to update the particles manually - do I need to call any other functions to make the particles render? Link to comment Share on other sites More sharing options...
lewster32 Posted July 10, 2014 Share Posted July 10, 2014 I think the problem is that doing it this way does not (as far as I can see) call preUpdate and postUpdate on the particles, and I suspect probably other things which they need within the Arcade physics system in order for their motion to be calculated. Harissa 1 Link to comment Share on other sites More sharing options...
Harissa Posted July 10, 2014 Author Share Posted July 10, 2014 Thanks for that suggestion. I tried: pauseUpdate() { console.log("updating during pause"); this.game.tweens.update(); this.game.world.preUpdate(); this.game.particles.update(); this.game.world.postUpdate(); }If I do this the particles now work, which is great. Unfortunately the rest of the physics objects carry on moving - but without collisions - which isn't quite what I wanted.If I only put in one of the preUpdate() or postUpdate() then the particles don't work. Hmm, looks like I might have to think about this again. What would be really nice is if each sprite or group could be paused individually but I'll probably have to write my own code for that. Link to comment Share on other sites More sharing options...
lewster32 Posted July 10, 2014 Share Posted July 10, 2014 Yeah I think the pause functionality of Phaser is intended to literally pause everything, and any kind of alternate functionality is going to have to be added separately. Link to comment Share on other sites More sharing options...
Harissa Posted July 10, 2014 Author Share Posted July 10, 2014 Ok, this was easier that I thought. For sprites that I want to be still while the game is paused I just put:update() { this.body.moves = !this.game.paused; // other update stuff here // .....}In the update handle for each sprite. It's all a bit hacky at the moment - it might be better to overload the sprite class and create a new global called something like "pauseGameSprites" but I'm definitely getting there. lewster32 1 Link to comment Share on other sites More sharing options...
jouniii Posted August 22, 2014 Share Posted August 22, 2014 Yeah I think the pause functionality of Phaser is intended to literally pause everything, and any kind of alternate functionality is going to have to be added separately. Sorry about hijacking this thread, however I noticed this is not the case for audio. Phaser pause code clearly sets audio to mute instead of pause. Is this intended or just a bug? I noticed this with crossfade looping audio I used and the timer resetting the crossfade was paused, but of course it did restart the audio too late because it was played out (although muted) while game (and timers) were paused. Link to comment Share on other sites More sharing options...
Recommended Posts