eps Posted December 7, 2018 Share Posted December 7, 2018 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! Quote Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2018 Share Posted December 8, 2018 Hello so do you need to stop all the rendering or just the animations? Quote Link to comment Share on other sites More sharing options...
eps Posted December 8, 2018 Author Share Posted December 8, 2018 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! Quote Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2018 Share Posted December 8, 2018 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 eps 1 Quote Link to comment Share on other sites More sharing options...
droggam Posted December 8, 2018 Share Posted December 8, 2018 @Deltakosh how u know so much? ? I wonder how to be advanced and master babylon yet im so on tillt rn i thoiught everything was easy till i started with physics imposter joints etx ? Quote Link to comment Share on other sites More sharing options...
Guest Posted December 8, 2018 Share Posted December 8, 2018 I wrote most of the code Quote Link to comment Share on other sites More sharing options...
eps Posted December 8, 2018 Author Share Posted December 8, 2018 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! GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.