eps

Pausing execution...

Recommended Posts

What's the most elegant way of pausing a BabylonJS animation or game?

 

I've got gameStateLive which I was going to set to true or false depending..  and I know you can have gameState for instance with various states as well...   So Live, Paused, GameOver, Start etc...  

 

Is it just to intercept this in the render and pre-render loops or something else?  I need a way to pause and un-pause the javascript and BabylonJS it calls.

 

Cheers!
 

Share this post


Link to post
Share on other sites

Interesting, I hadn't considered them separately...

I'd quite like the whole game to be paused - everything - so that a player can 'continue' from where they stopped after watching a rewarded advert for instance.  In my mind they have lost all their 'lives' and can 'go again' from that point, with their score intact and progress by watching a rewarded advert and then getting 3 more lives for instance.

 

Although saying that I quite like the idea of pausing the animations separately as well...!  It's not something I'd considered particularly, but could be used in specific situations.

For me the key item is being able to pause and un-pause the game.  If I can add some differentiation at a later point that would be great but is not essential.  I'm working on a 'list' of must-have elements vs. nice -to-have...  and trying to prioritise them accordingly, otherwise nothing would get completed!

Share this post


Link to post
Share on other sites

So to pause / unpause the best option is just to call engine.stopRenderLoop() to pause the rendering and  then call runRenderLoop to unpause (example: https://www.babylonjs-playground.com/#3A2PUF#5)

For animations, it is even easier, just call scene.animationsEnabled = false

Share this post


Link to post
Share on other sites
3 hours ago, Deltakosh said:

So to pause / unpause the best option is just to call engine.stopRenderLoop() to pause the rendering and  then call runRenderLoop to unpause (example: https://www.babylonjs-playground.com/#3A2PUF#5)

For animations, it is even easier, just call scene.animationsEnabled = false

#facepalm

 

stopRenderLoop - of course!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.