Quintus.Scenes = function(Q) { Q.scenes = {}; Q.stages = []; Q.Scene = Class.extend({ init: function(sceneFunc,opts) { this.opts = opts || {}; this.sceneFunc = sceneFunc; } }); // Set up or return a new scene Q.scene = function(name,sceneObj) { if(!sceneObj) { return Q.scenes[name]; } else { Q.scenes[name] = sceneObj; return sceneObj; } }; Q.overlap = function(o1,o2) { return !((o1.p.y+o1.p.h-1o2.p.y+o2.p.h-1) || (o1.p.x+o1.p.w-1o2.p.x+o2.p.w-1)); }; Q.Stage = Q.GameObject.extend({ // Should know whether or not the stage is paused defaults: { sort: false }, init: function(scene) { this.scene = scene; this.items = []; this.index = {}; this.removeList = []; if(scene) { this.options = _(this.defaults).clone(); _(this.options).extend(scene.opts); scene.sceneFunc(this); } if(this.options.sort && !_.isFunction(this.options.sort)) { this.options.sort = function(a,b) { return a.p.z - b.p.z; }; } }, each: function(callback) { for(var i=0,len=this.items.length;i 0) { for(var i=0,len=this.removeList.length;i