create()

Description

Create a new scene. Objects that are added in the init method will be added to canvas when the scene is loaded.

Arguments

name : String

The name of the scene. Will be used when loading the scene.

init : Function

A function that adds objects to the scene. this inside of the function refers to the scene instance, so to add objects use this.add(object). This function will be executed directly when the create() method executes. To add children after this stage, use the object that create() returns.

Return Value

Scene. Returns the newly created scene instance.

Examples

Example 1

We create a core instance and a text object, but we don't add it to the canvas. Then we create a new scene called menu. We pass a function as the init argument. Inside of that we add our text object to the scene. Then finally we load our scene, and our text object is added to canvas.