-
Notifications
You must be signed in to change notification settings - Fork 0
Scene Management
Cotton comes with an integrated scene
switching library. This makes it possible to completely switch out of your current level/game, do something else like show a cutscene, and then come back!
The default scene is loaded in main.lua
with the scene.set
function.
You can add additional scenes by calling:
scene.push(sceneObject)
You can add additional scenes by calling:
scene.pushOverlay(sceneObject)
You can go back to the previous scene like so:
scene.back()
To go back to a specific scene, call:
scene.backTo(sceneObject)
To check if a scene is in the scene stack.
scene.isInStack(sceneObject)
The scene object is the object that you give to the scene manager. Example of the most simple scene object:
local exampleScene = {}
function exampleScene.init()
-- log("I'm initialised!")
end
This function is called on initialisation.
function exampleScene.resume()
-- log("I'm resuming!")
end
This function is called when switching between scenes or resetting.
function exampleScene.update()
-- log("I'm updating")
end
This function is called in update loop.
function exampleScene.shutdown()
-- log("I'm shutting down")
end
This function is called on scene switching.