src/core/system.js in entityjs-0.3.2 vs src/core/system.js in entityjs-0.4.0

- old
+ new

@@ -42,10 +42,11 @@ var that = this; (function m(){ that.system_loop(); + if(that.running){ that.requestAnimationFrame(m, that.canvas); } })(); @@ -65,11 +66,11 @@ this.running = false; return this; }, //scale is currently not implemented! - init:function(canvasId, scale, contextType){ + init:function(canvasId, contextType){ //add comps here because system is defined earlier than other comps this.comp('polyfill tick timestep'); //setup canvas @@ -77,12 +78,10 @@ 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; @@ -96,26 +95,37 @@ re._c.mouse.i(); } if(re._c.touch){ re._c.touch.i(); } + this.system_loop = this.defaultLoop; + this.second = this.stepSize * 30; return this; }, /* Default main loop */ - system_loop:function(){ + defaultLoop:function(){ this.timestep(Math.min(this.tick() / 1000, this.maxTick), function(){ //update - re._c.update.update(this.stepSize); + this.update(); }); //clear this.clear(this.clearColor); - re._c.draw.draw(this.context); + this.draw(); + }, + + update:function(){ + re._c.update.update(this.stepSize); + }, + + draw:function(){ + //renders default drawlist + re.drawlist().drawlist(this.context); } }) .run(function(){ \ No newline at end of file