unload()

Unload the scene with the specified name.

Syntax unload(name)

Return Type Scenes

Description

Unload the scene with the specified name. This will remove all objects that have been added to this scene from the canvas.

Arguments

name : String
The name of the scene that is going to be unloaded.

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 we load our scene, and our text object is added to canvas. Finally we add an event handler, that will unload the scene when the text is clicked.

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");

startGame.bind("click tap", function () {
	canvas.scenes.unload("menu");
});
Output