mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
PointerConstraint now takes the scene camera it should use as a config option.
This commit is contained in:
parent
d9a9c7a5a1
commit
e194b95654
1 changed files with 16 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue