Detect Game End?

Hi,

How can I detect in a script external to the game that it has ended?

I would like to destroy the game at this point and instantiate a new one.

Thank you!

:wave:

You could emit an event from game.events (handled by an external listener) or you could just call an external function from your game logic.

Excellent, thank you. Do you know if I can call game.destroy(true) within the event callback, or within the external function?

You can call game.destroy() any time.

But you may need to listen for the game DESTROY event.

Excellent, thank you.