Using pre-defined layer sorting

You can sort sprites on a layer according to a predefined set of rules

You can change the draw order of sprites on a layer by setting a predefined sort function. Supported functions include bottomToTop and topToBottom, that are very useful in many types of top-down and isometric games. Observe what happens when the centers of the two objects cross.
App = function() { this.load = function() { wade.loadImage('/snippets/samples/dragon.png'); wade.loadImage('/snippets/samples/cc_logo.png'); }; this.init = function() { // create two objects on layer 5 var dragonSprite = new Sprite('/snippets/samples/dragon.png', 5); var dragon = new SceneObject(dragonSprite, 0, 0, -200); wade.addSceneObject(dragon); var logoSprite = new Sprite('/snippets/samples/cc_logo.png', 5); var logo = new SceneObject(logoSprite); wade.addSceneObject(logo); // set layer sorting to 'bottomToTop' for layer 5 wade.setLayerSorting(5, 'bottomToTop'); // move the dragon up and down dragon.moveTo(0, 200, 100); dragon.onMoveComplete = function() { var pos = this.getPosition(); this.moveTo(pos.x, -pos.y, 100); } }; };
Your code was executed successfully!