mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Merge pull request #831 from woutercommandeur/dev
Add movement data for pointerlocked mouse
This commit is contained in:
commit
ee30dd634a
1 changed files with 42 additions and 0 deletions
|
@ -129,6 +129,30 @@ Phaser.Pointer = function (game, id) {
|
||||||
*/
|
*/
|
||||||
this.screenY = -1;
|
this.screenY = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {number} rawMovementX - The horizontal raw relative movement of pointer in pixels since last event.
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
this.rawMovementX = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {number} rawMovementY - The vertical raw relative movement of pointer in pixels since last event.
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
this.rawMovementY = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {number} movementX - The horizontal processed relative movement of pointer in pixels since last event.
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
this.movementX = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {number} movementY - The vertical processed relative movement of pointer in pixels since last event.
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
this.movementY = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} x - The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
|
* @property {number} x - The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
|
||||||
* @default
|
* @default
|
||||||
|
@ -361,6 +385,15 @@ Phaser.Pointer.prototype = {
|
||||||
this.screenX = event.screenX;
|
this.screenX = event.screenX;
|
||||||
this.screenY = event.screenY;
|
this.screenY = event.screenY;
|
||||||
|
|
||||||
|
if (this.isMouse && this.game.input.mouse.locked && !fromClick) {
|
||||||
|
this.rawMovementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
|
||||||
|
this.rawMovementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
|
||||||
|
|
||||||
|
this.movementX += this.rawMovementX;
|
||||||
|
this.movementY += this.rawMovementY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
|
this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
|
||||||
this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;
|
this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;
|
||||||
|
|
||||||
|
@ -622,6 +655,15 @@ Phaser.Pointer.prototype = {
|
||||||
|
|
||||||
this.targetObject = null;
|
this.targetObject = null;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the movementX and movementY properties. Use in your update handler after retrieving the values.
|
||||||
|
* @method Phaser.Pointer#resetMovement
|
||||||
|
*/
|
||||||
|
resetMovement: function() {
|
||||||
|
this.movementX = 0;
|
||||||
|
this.movementY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue