src/core/system.js in entityjs-0.3.1 vs src/core/system.js in entityjs-0.3.2
- old
+ new
@@ -49,11 +49,11 @@
}
})();
}
- return this;
+ return this;
},
loop:function(m){
this.system_loop = m;
@@ -66,34 +66,39 @@
return this;
},
//scale is currently not implemented!
init:function(canvasId, scale, contextType){
- //init listeners
- if(re._c.keyboard){
- re._c.keyboard.i();
- }
- if(re._c.mouse){
- re._c.mouse.i();
- }
- if(re._c.touch){
- re._c.touch.i();
- }
//add comps here because system is defined earlier than other comps
this.comp('polyfill tick timestep');
//setup canvas
- this.canvas = re.$(canvasId);
+ if(re.is(canvasId, 'htmlcanvaselement')){
+ this.canvas = canvasId;
+ } else {
+ this.canvas = re.$(canvasId);
+ }
this.scale = scale || 1;
this.context = this.canvas.getContext(contextType || '2d');
var s = re.screen = re.e('screen');
this.sizeX = s.sizeX = this.canvas.width;
this.sizeY = s.sizeY = this.canvas.height;
+
+ //init listeners
+ if(re._c.keyboard){
+ re._c.keyboard.i();
+ }
+ if(re._c.mouse){
+ re._c.mouse.i();
+ }
+ if(re._c.touch){
+ re._c.touch.i();
+ }
return this;
},
/*
\ No newline at end of file