Cloning objects

How to create copies of scene objects

Sometimes you just want to create a copy of an existing scene object. It's pretty simple really, you only have to call object.clone().
App = function() { this.load = function() { wade.loadImage('/snippets/samples/cc_logo.png'); }; this.init = function() { // create an object and add it to the scene var logo = new SceneObject(new Sprite('/snippets/samples/cc_logo.png')); wade.addSceneObject(logo); // clone the object and add the clone to the scene var clonedLogo = logo.clone(); clonedLogo.setPosition(100, 0); wade.addSceneObject(clonedLogo); }; };
Your code was executed successfully!