Tutorial: Stages Lifecycle

Stages Lifecycle

GameStage has a lifecycle methods:

  1. constructor() - the default class method, is called once right after stage has registered in the app with System.registerStage.
    Nothing special happens here.

  2. register() - here ISystem, includes SystemSettings (systemSettings), ISystemAudio(audio) and INetwork(network) are attached to the GameStage.
    This is a place where assets should be added: Assets Manager, How to add and use audio

  3. init() - is called after the ISystem.startGameStage() is called, this stage called only once pear game. Assets, which were added at the register(2) stage, will be already loaded and ready to be used here.

    start() - is called right after init() the stage. If the stage will be stopped with the ISystem stopGameStage() and then restarted again it will be called without the init() on the second start.

  4. stop() - is called after ISystem.stopGameStage() is called. Can be used for shutdown the stage, remove listeners etc.

All methods above can be overwritten.