load()

Load the scene with the specified name.

Syntax load(name [, unload])

Return Type Scenes

Description

Load the scene with the specified name. There is also an option to unload the current scene first. This will add all objects that have been added to this scene to the canvas.

Arguments

name : String
The name of the scene that is going to be loaded.
unload : Boolean
True if the current scene should be unloaded first, false otherwise. Default: false

Return Value

Scenes. Returns the scenes module itself.

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.

View Example
Code
var canvas = oCanvas.create({
	canvas: "#canvas",
	background: "#ccc"
});

var startGame = canvas.display.text({
	x: 177,
	y: 170,
	origin: { x: "center", y: "top" },
	align: "center",
	font: "bold 30px sans-serif",
	text: "Start Game!",
	fill: "#000"
});

canvas.scenes.create("menu", function () {
	this.add(startGame);
});

canvas.scenes.load("menu");
Output