Skip to content

Commit

Permalink
fix handling of engine.render
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 5, 2015
1 parent d22b1b4 commit c46e915
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ var Engine = {};
controller: Grid
}
};

var engine = Common.extend(defaults, options);

if (element && !engine.render) {
engine.render = {
if (element || engine.render) {
var renderDefaults = {
element: element,
controller: Render
};

engine.render = Common.extend(renderDefaults, engine.render);
}

if (engine.render && engine.render.controller) {
Expand Down
10 changes: 8 additions & 2 deletions src/core/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,20 @@ var Runner = {};
Events.trigger(engine, 'tick', event);

// if world has been modified, clear the render scene graph
if (engine.world.isModified && engine.render.controller.clear)
if (engine.world.isModified
&& engine.render
&& engine.render.controller
&& engine.render.controller.clear) {
engine.render.controller.clear(engine.render);
}

// update
Engine.update(engine, delta, correction);

// render
Engine.render(engine);
if (engine.render) {
Engine.render(engine);
}

Events.trigger(engine, 'afterTick', event);
})();
Expand Down

0 comments on commit c46e915

Please sign in to comment.