Jump to content

Animate particles while game is paused


Harissa
 Share

Recommended Posts

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 use

pauseUpdate() {      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#entry20378

and 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

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

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.

Link to comment
Share on other sites

  • 1 month later...

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...