I’m trying to set change the scene timescale via a Javascript event block. I’m dong this because I want to set timescale when a message sent by another API is received.
I’m trying to achieve the following with javascript:
So far I’ve had a go with the following Javascript commands, they’re not doing anything:
Thanks for your input - it made me have a think about what was happening, and I placed some old school console debug statements to see what was going on.
As a result, I worked out that the event listener is added at the start of the game, when the splashScreen scene is active (it’s in an external events that’s added to all scenes, but the event listener is only added once at teh very start of the game). The event to change the timescale is invoked when the the game is paused while the mainGame scene is active.
However, even though mainGame is the running scene, runtimeScene still points to splashScreen.
As I have it, the event listener also sets the game state, a global variable. I’ll use this to pause scenes using GDevelop events.
FWIW, this is the solution I’ve come up with. It’s all in the external event, and seems to do the trick no matter which scene it’s actioned in. Upon resuming, gameState is reset to the state it was before pausing: