0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-25 13:39:06 -05:00

added MouseConstraint.create warning for omitted element

This commit is contained in:
liabru 2015-01-21 00:10:39 +00:00
parent af83e27ff0
commit b6603ca290

View file

@ -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',