From c46e9155e24091079263c7c56a4d20b6a8f34e26 Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 5 Jul 2015 15:57:12 +0100 Subject: [PATCH] fix handling of engine.render --- src/core/Engine.js | 8 +++++--- src/core/Runner.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/core/Engine.js b/src/core/Engine.js index ef9cd9b..eb22aa2 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -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) { diff --git a/src/core/Runner.js b/src/core/Runner.js index c302272..ab3bdfd 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -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); })();