From 5e6b22b0c88581328f3ff83fae34616abeaa31da Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 12 Aug 2015 23:27:39 +0100 Subject: [PATCH] fix demo for tests --- demo/js/Demo.js | 4 ++-- test/browser/TestDemo.js | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/demo/js/Demo.js b/demo/js/Demo.js index 3156297..b937031 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -573,7 +573,7 @@ // use the engine tick event to control our view _sceneEvents.push( - Events.on(_runner, 'beforeTick', function() { + Events.on(_engine, 'beforeTick', function() { var world = _engine.world, mouse = _mouseConstraint.mouse, render = _engine.render, @@ -1738,7 +1738,7 @@ Events.off(_world, _sceneEvents[i]); } - if (_runner.events) { + if (_runner && _runner.events) { for (i = 0; i < _sceneEvents.length; i++) Events.off(_runner, _sceneEvents[i]); } diff --git a/test/browser/TestDemo.js b/test/browser/TestDemo.js index 8603e45..989ce3a 100644 --- a/test/browser/TestDemo.js +++ b/test/browser/TestDemo.js @@ -14,7 +14,7 @@ var update = arg('--update'), updateAll = typeof arg('--updateAll') !== 'undefined', diff = arg('--diff'); -var resurrect = new Resurrect({ cleanup: true }), +var resurrect = new Resurrect({ cleanup: true, revive: false }), created = [], changed = []; @@ -60,12 +60,11 @@ var test = function(status) { }, demo); var worldEnd = page.evaluate(function(demo, frames) { - var engine = Matter.Demo._engine; + var engine = Matter.Demo._engine, + runner = Matter.Runner.create(); for (var j = 0; j <= frames; j += 1) { - Matter.Events.trigger(engine, 'tick', { timestamp: engine.timing.timestamp }); - Matter.Engine.update(engine, engine.timing.delta); - Matter.Events.trigger(engine, 'afterTick', { timestamp: engine.timing.timestamp }); + Matter.Runner.tick(runner, engine, j * runner.delta); } return engine.world;