unload()

Unload the scene instance.

Syntax unload()

Return Type Scene

Description

Unload the scene instance. This will remove all objects that have been added to the scene from the canvas.

Return Value

Scene. Returns the scene instance 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"
});

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

menu.load();

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