From 796faeb0699fabd52f3638c1695aa57fd7f46469 Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 24 May 2015 14:21:24 +0100 Subject: [PATCH] fix issue with mouse when changing renderers, closes #96 --- demo/js/Demo.js | 5 +++++ demo/js/lib/matter-tools/matter-tools-dev.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/demo/js/Demo.js b/demo/js/Demo.js index c99c19f9..ab1e71a4 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -1610,6 +1610,11 @@ _mouseConstraint = MouseConstraint.create(_engine); World.add(_engine.world, _mouseConstraint); }); + + // need to rebind mouse on render change + Events.on(_gui, 'setRenderer', function() { + Mouse.setElement(_mouseConstraint.mouse, _engine.render.canvas); + }); } // create a Matter.Inspector diff --git a/demo/js/lib/matter-tools/matter-tools-dev.js b/demo/js/lib/matter-tools/matter-tools-dev.js index 44aeccf2..93b5bfb7 100644 --- a/demo/js/lib/matter-tools/matter-tools-dev.js +++ b/demo/js/lib/matter-tools/matter-tools-dev.js @@ -1,5 +1,5 @@ /** -* matter-tools-dev.min.js 0.5.0-dev 2015-05-03 +* matter-tools-dev.min.js 0.5.0-dev 2015-05-24 * https://github.com/liabru/matter-tools * License: MIT */ @@ -236,7 +236,7 @@ options:options }); engine.render.options = options; - Mouse.setElement(engine.input.mouse, engine.render.canvas); + Events.trigger(gui, "setRenderer"); }; var _addBody = function(gui) { var engine = gui.engine;