PointerConstraint now takes the scene camera it should use as a config option.

This commit is contained in:
Richard Davey 2017-11-28 11:16:23 +00:00
parent d9a9c7a5a1
commit e194b95654

View file

@ -3,6 +3,7 @@ var Class = require('../../utils/Class');
var Composite = require('./lib/body/Composite');
var Constraint = require('./lib/constraint/Constraint');
var Detector = require('./lib/collision/Detector');
var GetFastValue = require('../../utils/object/GetFastValue');
var Merge = require('../../utils/object/Merge');
var Sleeping = require('./lib/core/Sleeping');
var Vertices = require('./lib/geometry/Vertices');
@ -35,6 +36,19 @@ var PointerConstraint = new Class({
this.world = world;
var camera = GetFastValue(options, 'camera', null);
if (!camera)
{
this.camera = scene.sys.cameras.main;
}
else
{
this.camera = camera;
delete options.camera;
}
this.pointer = null;
this.active = true;
@ -109,7 +123,8 @@ var PointerConstraint = new Class({
}
else
{
var position = pointer.position;
// var position = this.camera.screenToCamera({ x: pointer.position.x, y: pointer.position.y });
var position = this.pointer.positionToCamera(this.camera);
if (constraint.bodyB)
{