Named scene objects

Set names for your objects and access them via their name

If you don't want to store references to your objects, you can give them a name with SceneObject.setName(). The name can later be used to retrieve your objects witha a call to wade.getSceneObject().
App = function() { this.init = function() { // create a text object var textSprite = new TextSprite('Click anywhere', '32px Arial', 'red', 'center'); var textObject = new SceneObject(textSprite); // add the object to the scene wade.addSceneObject(textObject); // give it a name textObject.setName('myText'); }; this.onClick = function(eventData) { // move the text var pos = eventData.screenPosition; wade.getSceneObject('myText').moveTo(pos.x, pos.y, 100); }; };
Your code was executed successfully!