As we mentioned earlier, one of the main responsibilities of the Director is to manage the flow control of the scenes.
To do this, the director provides an API:
director.replace( new_scene ) director.push( new_scene ) director.pop()
Use Director.replace to replace the current scene with a new one, and use Director.push to push a new scene on the stack. The old scene will be stack, under the new one. You can remove an scene from the stack using Director.pop.
When a new scene is pushed or replaced, these actions will be executed:
# calls on_exit on the 'old' scene outgoing_scene.on_exit() # disable handlers outgoing_scnee.enable_handlers( False) # calls on_enter() on the 'new' scene incoming_scene.on_enter() # enable handlers incoming_scnee.enable_handlers( True )
When an Scene is entered, it will propagate the on_enter message to all it's children, and it's children will do the same with it's children, and so on.
The same happens with the on_exit message.