From b6603ca290d360346b7fd1d64819f7800a22cb2d Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 21 Jan 2015 00:10:39 +0000 Subject: [PATCH] added MouseConstraint.create warning for omitted element --- src/constraint/MouseConstraint.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/constraint/MouseConstraint.js b/src/constraint/MouseConstraint.js index 21844385..e0072ade 100644 --- a/src/constraint/MouseConstraint.js +++ b/src/constraint/MouseConstraint.js @@ -22,7 +22,14 @@ var MouseConstraint = {}; * @return {MouseConstraint} A new MouseConstraint */ MouseConstraint.create = function(engine, options) { - var mouse = (options && options.mouse) || Mouse.create(engine.render.canvas); + var mouse = (engine ? engine.mouse : null) || (options ? options.mouse : null); + + if (!mouse && engine && engine.render && engine.render.canvas) { + mouse = Mouse.create(engine.render.canvas); + } else { + mouse = Mouse.create(); + Common.log('MouseConstraint.create: options.mouse was undefined, engine.render.canvas was undefined, may not function as expected', 'warn'); + } var constraint = Constraint.create({ label: 'Mouse Constraint',