2013-08-31 12:54:59 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2016-04-04 21:15:01 +00:00
|
|
|
* @copyright 2016 Photon Storm Ltd.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-09-16 16:35:08 +00:00
|
|
|
* A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen.
|
2013-08-31 12:54:59 +00:00
|
|
|
*
|
2013-10-01 12:54:29 +00:00
|
|
|
* @class Phaser.Pointer
|
|
|
|
* @constructor
|
|
|
|
* @param {Phaser.Game} game - A reference to the currently running game.
|
2013-11-25 03:13:04 +00:00
|
|
|
* @param {number} id - The ID of the Pointer object within the game. Each game can have up to 10 active pointers.
|
2015-09-22 02:22:45 +00:00
|
|
|
* @param {Phaser.PointerMode} pointerMode=(CURSOR|CONTACT) - The operational mode of this pointer, eg. CURSOR or TOUCH.
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
2015-09-22 02:22:45 +00:00
|
|
|
Phaser.Pointer = function (game, id, pointerMode) {
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2013-10-02 14:05:55 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {Phaser.Game} game - A reference to the currently running game.
|
2013-10-02 14:05:55 +00:00
|
|
|
*/
|
|
|
|
this.game = game;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {number} id - The ID of the Pointer object within the game. Each game can have up to 10 active pointers.
|
2013-10-02 14:05:55 +00:00
|
|
|
*/
|
|
|
|
this.id = id;
|
|
|
|
|
2014-05-06 01:45:10 +00:00
|
|
|
/**
|
|
|
|
* @property {number} type - The const type of this object.
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
this.type = Phaser.POINTER;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {boolean} exists - A Pointer object that exists is allowed to be checked for physics collisions and overlaps.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.exists = true;
|
|
|
|
|
2014-05-01 22:35:23 +00:00
|
|
|
/**
|
|
|
|
* @property {number} identifier - The identifier property of the Pointer as set by the DOM event when this Pointer is started.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.identifier = 0;
|
|
|
|
|
2014-05-02 11:14:05 +00:00
|
|
|
/**
|
|
|
|
* @property {number} pointerId - The pointerId property of the Pointer as set by the DOM event when this Pointer is started. The browser can and will recycle this value.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.pointerId = null;
|
|
|
|
|
2015-09-22 02:22:45 +00:00
|
|
|
/**
|
|
|
|
* @property {Phaser.PointerMode} pointerMode - The operational mode of this pointer.
|
|
|
|
*/
|
|
|
|
this.pointerMode = pointerMode || (Phaser.PointerMode.CURSOR | Phaser.PointerMode.CONTACT);
|
|
|
|
|
2014-05-01 22:35:23 +00:00
|
|
|
/**
|
|
|
|
* @property {any} target - The target property of the Pointer as set by the DOM event when this Pointer is started.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.target = null;
|
|
|
|
|
|
|
|
/**
|
2015-07-12 10:47:20 +00:00
|
|
|
* The button property of the most recent DOM event when this Pointer is started.
|
|
|
|
* You should not rely on this value for accurate button detection, instead use the Pointer properties
|
|
|
|
* `leftButton`, `rightButton`, `middleButton` and so on.
|
|
|
|
* @property {any} button
|
2014-05-01 22:35:23 +00:00
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.button = null;
|
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If this Pointer is a Mouse or Pen / Stylus then you can access its left button directly through this property.
|
|
|
|
*
|
|
|
|
* The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained
|
|
|
|
* button control.
|
|
|
|
*
|
2015-07-17 11:23:54 +00:00
|
|
|
* @property {Phaser.DeviceButton} leftButton
|
2015-07-07 15:53:56 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.leftButton = new Phaser.DeviceButton(this, Phaser.Pointer.LEFT_BUTTON);
|
2015-07-07 15:53:56 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If this Pointer is a Mouse or Pen / Stylus then you can access its middle button directly through this property.
|
|
|
|
*
|
|
|
|
* The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained
|
|
|
|
* button control.
|
|
|
|
*
|
|
|
|
* Please see the DeviceButton docs for details on browser button limitations.
|
|
|
|
*
|
2015-07-17 11:23:54 +00:00
|
|
|
* @property {Phaser.DeviceButton} middleButton
|
2015-07-07 15:53:56 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.middleButton = new Phaser.DeviceButton(this, Phaser.Pointer.MIDDLE_BUTTON);
|
2015-07-07 15:53:56 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If this Pointer is a Mouse or Pen / Stylus then you can access its right button directly through this property.
|
|
|
|
*
|
|
|
|
* The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained
|
|
|
|
* button control.
|
|
|
|
*
|
|
|
|
* Please see the DeviceButton docs for details on browser button limitations.
|
|
|
|
*
|
2015-07-17 11:23:54 +00:00
|
|
|
* @property {Phaser.DeviceButton} rightButton
|
2015-07-07 15:53:56 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.rightButton = new Phaser.DeviceButton(this, Phaser.Pointer.RIGHT_BUTTON);
|
2015-07-07 15:53:56 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If this Pointer is a Mouse or Pen / Stylus then you can access its X1 (back) button directly through this property.
|
|
|
|
*
|
|
|
|
* The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained
|
|
|
|
* button control.
|
|
|
|
*
|
|
|
|
* Please see the DeviceButton docs for details on browser button limitations.
|
|
|
|
*
|
2015-07-17 11:23:54 +00:00
|
|
|
* @property {Phaser.DeviceButton} backButton
|
2015-07-07 15:53:56 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.backButton = new Phaser.DeviceButton(this, Phaser.Pointer.BACK_BUTTON);
|
2015-07-07 15:53:56 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If this Pointer is a Mouse or Pen / Stylus then you can access its X2 (forward) button directly through this property.
|
|
|
|
*
|
|
|
|
* The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained
|
|
|
|
* button control.
|
|
|
|
*
|
|
|
|
* Please see the DeviceButton docs for details on browser button limitations.
|
|
|
|
*
|
2015-07-17 11:23:54 +00:00
|
|
|
* @property {Phaser.DeviceButton} forwardButton
|
2015-07-07 15:53:56 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.forwardButton = new Phaser.DeviceButton(this, Phaser.Pointer.FORWARD_BUTTON);
|
2015-07-07 15:53:56 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If this Pointer is a Pen / Stylus then you can access its eraser button directly through this property.
|
|
|
|
*
|
|
|
|
* The DeviceButton has its own properties such as `isDown`, `duration` and methods like `justReleased` for more fine-grained
|
|
|
|
* button control.
|
|
|
|
*
|
|
|
|
* Please see the DeviceButton docs for details on browser button limitations.
|
|
|
|
*
|
2015-07-17 11:23:54 +00:00
|
|
|
* @property {Phaser.DeviceButton} eraserButton
|
2015-07-07 15:53:56 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.eraserButton = new Phaser.DeviceButton(this, Phaser.Pointer.ERASER_BUTTON);
|
2015-07-07 15:53:56 +00:00
|
|
|
|
2013-09-10 19:40:34 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} _holdSent - Local private variable to store the status of dispatching a hold event.
|
2013-09-10 19:40:34 +00:00
|
|
|
* @private
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this._holdSent = false;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {array} _history - Local private variable storing the short-term history of pointer movements.
|
2013-09-10 19:40:34 +00:00
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._history = [];
|
|
|
|
|
|
|
|
/**
|
2014-05-01 22:35:23 +00:00
|
|
|
* @property {number} _nextDrop - Local private variable storing the time at which the next history drop should occur.
|
2013-09-10 19:40:34 +00:00
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._nextDrop = 0;
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} _stateReset - Monitor events outside of a state reset loop.
|
|
|
|
* @private
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this._stateReset = false;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {boolean} withinGame - true if the Pointer is over the game canvas, otherwise false.
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.withinGame = false;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} clientX - The horizontal coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.clientX = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} clientY - The vertical coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.clientY = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} pageX - The horizontal coordinate of the Pointer relative to whole document.
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.pageX = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} pageY - The vertical coordinate of the Pointer relative to whole document.
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.pageY = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} screenX - The horizontal coordinate of the Pointer relative to the screen.
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.screenX = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} screenY - The vertical coordinate of the Pointer relative to the screen.
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.screenY = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} rawMovementX - The horizontal raw relative movement of the Pointer in pixels since last event.
|
2014-05-17 09:32:11 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-05-17 09:27:31 +00:00
|
|
|
this.rawMovementX = 0;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} rawMovementY - The vertical raw relative movement of the Pointer in pixels since last event.
|
2014-05-17 09:32:11 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-05-17 09:27:31 +00:00
|
|
|
this.rawMovementY = 0;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} movementX - The horizontal processed relative movement of the Pointer in pixels since last event.
|
2014-05-17 09:32:11 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-05-17 09:27:31 +00:00
|
|
|
this.movementX = 0;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} movementY - The vertical processed relative movement of the Pointer in pixels since last event.
|
2014-05-17 09:32:11 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2014-05-17 09:27:31 +00:00
|
|
|
this.movementY = 0;
|
|
|
|
|
2014-05-17 09:32:11 +00:00
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} x - The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.x = -1;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} y - The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
2013-09-10 19:40:34 +00:00
|
|
|
*/
|
|
|
|
this.y = -1;
|
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* @property {boolean} isMouse - If the Pointer is a mouse or pen / stylus this is true, otherwise false.
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2015-07-20 13:01:21 +00:00
|
|
|
this.isMouse = (id === 0);
|
2013-09-10 19:40:34 +00:00
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If the Pointer is touching the touchscreen, or *any* mouse or pen button is held down, isDown is set to true.
|
|
|
|
* If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isDown.
|
|
|
|
* @property {boolean} isDown
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.isDown = false;
|
|
|
|
|
|
|
|
/**
|
2015-07-17 12:52:09 +00:00
|
|
|
* If the Pointer is not touching the touchscreen, or *all* mouse or pen buttons are up, isUp is set to true.
|
|
|
|
* If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isUp.
|
|
|
|
* @property {boolean} isUp
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.isUp = true;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {number} timeDown - A timestamp representing when the Pointer first touched the touchscreen.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.timeDown = 0;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {number} timeUp - A timestamp representing when the Pointer left the touchscreen.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.timeUp = 0;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {number} previousTapTime - A timestamp representing when the Pointer was last tapped or clicked.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.previousTapTime = 0;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {number} totalTouches - The total number of times this Pointer has been touched to the touchscreen.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.totalTouches = 0;
|
|
|
|
|
|
|
|
/**
|
2014-05-19 17:49:16 +00:00
|
|
|
* @property {number} msSinceLastClick - The number of milliseconds since the last click or touch event.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.msSinceLastClick = Number.MAX_VALUE;
|
|
|
|
|
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {any} targetObject - The Game Object this Pointer is currently over / touching / dragging.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-09-10 19:40:34 +00:00
|
|
|
this.targetObject = null;
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} active - An active pointer is one that is currently pressed down on the display. A Mouse is always active.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @default
|
|
|
|
*/
|
2013-08-31 12:54:59 +00:00
|
|
|
this.active = false;
|
|
|
|
|
2014-08-28 23:47:49 +00:00
|
|
|
/**
|
|
|
|
* @property {boolean} dirty - A dirty pointer needs to re-poll any interactive objects it may have been over, regardless if it has moved or not.
|
|
|
|
* @default
|
|
|
|
*/
|
|
|
|
this.dirty = false;
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {Phaser.Point} position - A Phaser.Point object containing the current x/y values of the pointer on the display.
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-08-31 12:54:59 +00:00
|
|
|
this.position = new Phaser.Point();
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {Phaser.Point} positionDown - A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display.
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-08-31 12:54:59 +00:00
|
|
|
this.positionDown = new Phaser.Point();
|
2014-03-31 14:07:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {Phaser.Point} positionUp - A Phaser.Point object containing the x/y values of the pointer when it was last released.
|
|
|
|
*/
|
|
|
|
this.positionUp = new Phaser.Point();
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-13 06:49:24 +00:00
|
|
|
* A Phaser.Circle that is centered on the x/y coordinates of this pointer, useful for hit detection.
|
|
|
|
* The Circle size is 44px (Apples recommended "finger tip" size).
|
2013-10-01 12:54:29 +00:00
|
|
|
* @property {Phaser.Circle} circle
|
|
|
|
*/
|
2013-08-31 12:54:59 +00:00
|
|
|
this.circle = new Phaser.Circle(0, 0, 44);
|
|
|
|
|
2014-11-01 08:04:17 +00:00
|
|
|
/**
|
|
|
|
* Click trampolines associated with this pointer. See `addClickTrampoline`.
|
|
|
|
* @property {object[]|null} _clickTrampolines
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._clickTrampolines = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When the Pointer has click trampolines the last target object is stored here
|
|
|
|
* so it can be used to check for validity of the trampoline in a post-Up/'stop'.
|
|
|
|
* @property {object} _trampolineTargetObject
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._trampolineTargetObject = null;
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
};
|
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
/**
|
|
|
|
* No buttons at all.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.NO_BUTTON = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Left Mouse button, or in PointerEvent devices a Touch contact or Pen contact.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.LEFT_BUTTON = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Right Mouse button, or in PointerEvent devices a Pen contact with a barrel button.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.RIGHT_BUTTON = 2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Middle Mouse button.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.MIDDLE_BUTTON = 4;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The X1 button. This is typically the mouse Back button, but is often reconfigured.
|
|
|
|
* On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.BACK_BUTTON = 8;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The X2 button. This is typically the mouse Forward button, but is often reconfigured.
|
|
|
|
* On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.FORWARD_BUTTON = 16;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Eraser pen button on PointerEvent supported devices only.
|
|
|
|
* @constant
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
Phaser.Pointer.ERASER_BUTTON = 32;
|
|
|
|
|
2013-08-31 20:50:34 +00:00
|
|
|
Phaser.Pointer.prototype = {
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
/**
|
|
|
|
* Resets the states of all the button booleans.
|
|
|
|
*
|
|
|
|
* @method Phaser.Pointer#resetButtons
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
resetButtons: function () {
|
|
|
|
|
2015-07-12 10:56:25 +00:00
|
|
|
this.isDown = false;
|
2015-07-17 12:52:09 +00:00
|
|
|
this.isUp = true;
|
|
|
|
|
|
|
|
if (this.isMouse)
|
|
|
|
{
|
|
|
|
this.leftButton.reset();
|
|
|
|
this.middleButton.reset();
|
|
|
|
this.rightButton.reset();
|
|
|
|
this.backButton.reset();
|
|
|
|
this.forwardButton.reset();
|
|
|
|
this.eraserButton.reset();
|
|
|
|
}
|
2015-07-12 10:56:25 +00:00
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
},
|
|
|
|
|
2015-07-28 13:18:23 +00:00
|
|
|
/**
|
|
|
|
* Called by updateButtons.
|
|
|
|
*
|
|
|
|
* @method Phaser.Pointer#processButtonsDown
|
|
|
|
* @private
|
|
|
|
* @param {integer} buttons - The DOM event.buttons property.
|
|
|
|
* @param {MouseEvent} event - The DOM event.
|
|
|
|
*/
|
|
|
|
processButtonsDown: function (buttons, event) {
|
|
|
|
|
|
|
|
// Note: These are bitwise checks, not booleans
|
|
|
|
|
|
|
|
if (Phaser.Pointer.LEFT_BUTTON & buttons)
|
|
|
|
{
|
|
|
|
this.leftButton.start(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Phaser.Pointer.RIGHT_BUTTON & buttons)
|
|
|
|
{
|
|
|
|
this.rightButton.start(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Phaser.Pointer.MIDDLE_BUTTON & buttons)
|
|
|
|
{
|
|
|
|
this.middleButton.start(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Phaser.Pointer.BACK_BUTTON & buttons)
|
|
|
|
{
|
|
|
|
this.backButton.start(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Phaser.Pointer.FORWARD_BUTTON & buttons)
|
|
|
|
{
|
|
|
|
this.forwardButton.start(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Phaser.Pointer.ERASER_BUTTON & buttons)
|
|
|
|
{
|
|
|
|
this.eraserButton.start(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by updateButtons.
|
|
|
|
*
|
|
|
|
* @method Phaser.Pointer#processButtonsUp
|
|
|
|
* @private
|
|
|
|
* @param {integer} buttons - The DOM event.buttons property.
|
|
|
|
* @param {MouseEvent} event - The DOM event.
|
|
|
|
*/
|
|
|
|
processButtonsUp: function (button, event) {
|
|
|
|
|
|
|
|
// Note: These are bitwise checks, not booleans
|
|
|
|
|
|
|
|
if (button === Phaser.Mouse.LEFT_BUTTON)
|
|
|
|
{
|
|
|
|
this.leftButton.stop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button === Phaser.Mouse.RIGHT_BUTTON)
|
|
|
|
{
|
|
|
|
this.rightButton.stop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button === Phaser.Mouse.MIDDLE_BUTTON)
|
|
|
|
{
|
|
|
|
this.middleButton.stop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button === Phaser.Mouse.BACK_BUTTON)
|
|
|
|
{
|
|
|
|
this.backButton.stop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button === Phaser.Mouse.FORWARD_BUTTON)
|
|
|
|
{
|
|
|
|
this.forwardButton.stop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button === 5)
|
|
|
|
{
|
|
|
|
this.eraserButton.stop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
/**
|
|
|
|
* Called when the event.buttons property changes from zero.
|
|
|
|
* Contains a button bitmask.
|
|
|
|
*
|
|
|
|
* @method Phaser.Pointer#updateButtons
|
|
|
|
* @protected
|
2015-07-09 18:26:00 +00:00
|
|
|
* @param {MouseEvent} event - The DOM event.
|
2015-07-07 15:53:56 +00:00
|
|
|
*/
|
2015-07-09 18:26:00 +00:00
|
|
|
updateButtons: function (event) {
|
|
|
|
|
2015-07-12 10:47:20 +00:00
|
|
|
this.button = event.button;
|
|
|
|
|
2015-07-28 13:18:23 +00:00
|
|
|
var down = (event.type.toLowerCase().substr(-4) === 'down');
|
2015-07-07 15:53:56 +00:00
|
|
|
|
2015-07-28 13:18:23 +00:00
|
|
|
if (event.buttons !== undefined)
|
2015-07-07 15:53:56 +00:00
|
|
|
{
|
2015-07-28 13:18:23 +00:00
|
|
|
if (down)
|
2015-07-23 19:54:59 +00:00
|
|
|
{
|
2015-07-28 13:18:23 +00:00
|
|
|
this.processButtonsDown(event.buttons, event);
|
2015-07-23 19:54:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-28 13:18:23 +00:00
|
|
|
this.processButtonsUp(event.button, event);
|
2015-07-23 19:54:59 +00:00
|
|
|
}
|
2015-07-17 13:11:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-23 19:54:59 +00:00
|
|
|
// No buttons property (like Safari on OSX when using a trackpad)
|
2015-07-28 13:18:23 +00:00
|
|
|
if (down)
|
2015-07-23 19:54:59 +00:00
|
|
|
{
|
|
|
|
this.leftButton.start(event);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.leftButton.stop(event);
|
|
|
|
this.rightButton.stop(event);
|
|
|
|
}
|
2015-07-17 13:11:11 +00:00
|
|
|
}
|
2015-07-07 15:53:56 +00:00
|
|
|
|
2015-07-09 18:26:00 +00:00
|
|
|
// On OS X (and other devices with trackpads) you have to press CTRL + the pad
|
2016-02-17 01:46:55 +00:00
|
|
|
// to initiate a right-click event, so we'll check for that here ONLY if
|
|
|
|
// event.buttons = 1 (i.e. they only have a 1 button mouse or trackpad)
|
2015-07-28 13:18:23 +00:00
|
|
|
|
2016-02-17 01:46:55 +00:00
|
|
|
if (event.buttons === 1 && event.ctrlKey && this.leftButton.isDown)
|
2015-07-09 18:26:00 +00:00
|
|
|
{
|
2016-02-17 01:26:35 +00:00
|
|
|
this.leftButton.stop(event);
|
2015-07-17 12:52:09 +00:00
|
|
|
this.rightButton.start(event);
|
2015-07-09 18:26:00 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 10:56:25 +00:00
|
|
|
this.isUp = true;
|
|
|
|
this.isDown = false;
|
|
|
|
|
2015-07-17 12:52:09 +00:00
|
|
|
if (this.leftButton.isDown || this.rightButton.isDown || this.middleButton.isDown || this.backButton.isDown || this.forwardButton.isDown || this.eraserButton.isDown)
|
2015-07-12 10:56:25 +00:00
|
|
|
{
|
|
|
|
this.isUp = false;
|
|
|
|
this.isDown = true;
|
|
|
|
}
|
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* Called when the Pointer is pressed onto the touchscreen.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#start
|
2014-05-02 11:14:05 +00:00
|
|
|
* @param {any} event - The DOM event from the browser.
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
|
|
|
start: function (event) {
|
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
var input = this.game.input;
|
|
|
|
|
2014-05-02 11:14:05 +00:00
|
|
|
if (event['pointerId'])
|
|
|
|
{
|
|
|
|
this.pointerId = event.pointerId;
|
|
|
|
}
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
this.identifier = event.identifier;
|
|
|
|
this.target = event.target;
|
|
|
|
|
2015-07-17 11:23:54 +00:00
|
|
|
if (this.isMouse)
|
|
|
|
{
|
|
|
|
this.updateButtons(event);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.isDown = true;
|
|
|
|
this.isUp = false;
|
|
|
|
}
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
this.active = true;
|
|
|
|
this.withinGame = true;
|
2014-08-28 23:47:49 +00:00
|
|
|
this.dirty = false;
|
2015-08-20 11:47:50 +00:00
|
|
|
|
|
|
|
this._history = [];
|
2014-11-01 08:04:17 +00:00
|
|
|
this._clickTrampolines = null;
|
|
|
|
this._trampolineTargetObject = null;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
// Work out how long it has been since the last click
|
2014-11-08 20:01:10 +00:00
|
|
|
this.msSinceLastClick = this.game.time.time - this.timeDown;
|
|
|
|
this.timeDown = this.game.time.time;
|
2013-08-31 12:54:59 +00:00
|
|
|
this._holdSent = false;
|
|
|
|
|
|
|
|
// This sets the x/y and other local values
|
2014-02-12 01:25:36 +00:00
|
|
|
this.move(event, true);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
// x and y are the old values here?
|
|
|
|
this.positionDown.setTo(this.x, this.y);
|
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
if (input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH ||
|
|
|
|
input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE ||
|
|
|
|
(input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0))
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
input.x = this.x;
|
|
|
|
input.y = this.y;
|
|
|
|
input.position.setTo(this.x, this.y);
|
|
|
|
input.onDown.dispatch(this, event);
|
|
|
|
input.resetSpeed(this.x, this.y);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._stateReset = false;
|
2015-09-29 15:06:44 +00:00
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
this.totalTouches++;
|
|
|
|
|
|
|
|
if (this.targetObject !== null)
|
|
|
|
{
|
2013-09-08 21:38:19 +00:00
|
|
|
this.targetObject._touchedHandler(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2014-01-20 20:14:34 +00:00
|
|
|
* Called by the Input Manager.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#update
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-08-31 12:54:59 +00:00
|
|
|
update: function () {
|
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
var input = this.game.input;
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
if (this.active)
|
|
|
|
{
|
2014-08-28 23:47:49 +00:00
|
|
|
// Force a check?
|
|
|
|
if (this.dirty)
|
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
if (input.interactiveItems.total > 0)
|
2014-08-28 23:47:49 +00:00
|
|
|
{
|
2014-10-29 06:26:35 +00:00
|
|
|
this.processInteractiveObjects(false);
|
2014-08-28 23:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.dirty = false;
|
|
|
|
}
|
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
if (this._holdSent === false && this.duration >= input.holdRate)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
if (input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH ||
|
|
|
|
input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE ||
|
|
|
|
(input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0))
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
input.onHold.dispatch(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._holdSent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the droppings history
|
2015-09-29 15:06:44 +00:00
|
|
|
if (input.recordPointerHistory && this.game.time.time >= this._nextDrop)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
this._nextDrop = this.game.time.time + input.recordRate;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
this._history.push({
|
|
|
|
x: this.position.x,
|
|
|
|
y: this.position.y
|
|
|
|
});
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
if (this._history.length > input.recordLimit)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
this._history.shift();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
|
|
|
* Called when the Pointer is moved.
|
2014-07-15 10:20:43 +00:00
|
|
|
*
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#move
|
2013-11-25 03:13:04 +00:00
|
|
|
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
|
2014-02-12 01:25:36 +00:00
|
|
|
* @param {boolean} [fromClick=false] - Was this called from the click event?
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
2014-02-12 01:25:36 +00:00
|
|
|
move: function (event, fromClick) {
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2015-08-20 11:47:50 +00:00
|
|
|
var input = this.game.input;
|
|
|
|
|
|
|
|
if (input.pollLocked)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-17 12:52:09 +00:00
|
|
|
if (fromClick === undefined) { fromClick = false; }
|
|
|
|
|
|
|
|
if (event.button !== undefined)
|
|
|
|
{
|
|
|
|
this.button = event.button;
|
|
|
|
}
|
2014-02-12 01:25:36 +00:00
|
|
|
|
2015-07-27 12:34:06 +00:00
|
|
|
if (fromClick && this.isMouse)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-07-09 18:26:00 +00:00
|
|
|
this.updateButtons(event);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.clientX = event.clientX;
|
|
|
|
this.clientY = event.clientY;
|
|
|
|
|
|
|
|
this.pageX = event.pageX;
|
|
|
|
this.pageY = event.pageY;
|
|
|
|
|
|
|
|
this.screenX = event.screenX;
|
|
|
|
this.screenY = event.screenY;
|
|
|
|
|
2015-08-20 11:47:50 +00:00
|
|
|
if (this.isMouse && input.mouse.locked && !fromClick)
|
2014-05-19 12:11:58 +00:00
|
|
|
{
|
2014-05-17 09:27:31 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-08-20 11:47:50 +00:00
|
|
|
this.x = (this.pageX - this.game.scale.offset.x) * input.scale.x;
|
|
|
|
this.y = (this.pageY - this.game.scale.offset.y) * input.scale.y;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
this.position.setTo(this.x, this.y);
|
|
|
|
this.circle.x = this.x;
|
|
|
|
this.circle.y = this.y;
|
|
|
|
|
2015-08-20 11:47:50 +00:00
|
|
|
if (input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH ||
|
|
|
|
input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE ||
|
|
|
|
(input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0))
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-08-20 11:47:50 +00:00
|
|
|
input.activePointer = this;
|
|
|
|
input.x = this.x;
|
|
|
|
input.y = this.y;
|
|
|
|
input.position.setTo(input.x, input.y);
|
|
|
|
input.circle.x = input.x;
|
|
|
|
input.circle.y = input.y;
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
2014-05-19 17:49:16 +00:00
|
|
|
this.withinGame = this.game.scale.bounds.contains(this.pageX, this.pageY);
|
|
|
|
|
2014-01-20 20:14:34 +00:00
|
|
|
// If the game is paused we don't process any target objects or callbacks
|
2013-08-31 12:54:59 +00:00
|
|
|
if (this.game.paused)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-08-20 11:47:50 +00:00
|
|
|
var i = input.moveCallbacks.length;
|
2014-05-14 02:01:24 +00:00
|
|
|
|
|
|
|
while (i--)
|
|
|
|
{
|
2015-08-20 11:47:50 +00:00
|
|
|
input.moveCallbacks[i].callback.call(input.moveCallbacks[i].context, this, this.x, this.y, fromClick);
|
2014-05-14 02:01:24 +00:00
|
|
|
}
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
// Easy out if we're dragging something and it still exists
|
2013-11-25 03:13:04 +00:00
|
|
|
if (this.targetObject !== null && this.targetObject.isDragged === true)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2013-11-25 03:13:04 +00:00
|
|
|
if (this.targetObject.update(this) === false)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
this.targetObject = null;
|
|
|
|
}
|
|
|
|
}
|
2015-08-20 11:47:50 +00:00
|
|
|
else if (input.interactiveItems.total > 0)
|
2014-07-15 10:20:43 +00:00
|
|
|
{
|
|
|
|
this.processInteractiveObjects(fromClick);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process all interactive objects to find out which ones were updated in the recent Pointer move.
|
|
|
|
*
|
|
|
|
* @method Phaser.Pointer#processInteractiveObjects
|
|
|
|
* @protected
|
|
|
|
* @param {boolean} [fromClick=false] - Was this called from the click event?
|
2014-08-27 20:24:53 +00:00
|
|
|
* @return {boolean} True if this method processes an object (i.e. a Sprite becomes the Pointers currentTarget), otherwise false.
|
2014-07-15 10:20:43 +00:00
|
|
|
*/
|
|
|
|
processInteractiveObjects: function (fromClick) {
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
// Work out which object is on the top
|
The `DisplayObject.renderOrderID` used to run in reverse. I.e. in a display list with 10 sprites on it, the first sprite (at the bottom of the list, rendering behind all the others) would have a `renderOrderID` of 9, where-as the top-most sprite, rendering above all others, would have a `renderOrderID` of 0. While this didn't cause any side-effects internally, it's arguably illogical. So the process has been reversed, and `renderOrderID`s are now accumulative, starting at zero each frame, and increasing as it iterates down the display list. So the higher the ID, the more "on-top" of the output the object is.
`InputHandler.validForInput` and `Pointer.processInteractiveObjects` have been updated to reflect the new `renderOrderID` sequence (see above).
2016-06-09 11:32:37 +00:00
|
|
|
var highestRenderOrderID = 0;
|
2014-10-29 06:26:35 +00:00
|
|
|
var highestInputPriorityID = -1;
|
|
|
|
var candidateTarget = null;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2014-07-15 10:20:43 +00:00
|
|
|
// First pass gets all objects that the pointer is over that DON'T use pixelPerfect checks and get the highest ID
|
|
|
|
// We know they'll be valid for input detection but not which is the top just yet
|
|
|
|
|
|
|
|
var currentNode = this.game.input.interactiveItems.first;
|
|
|
|
|
2014-10-29 06:26:35 +00:00
|
|
|
while (currentNode)
|
2013-09-08 12:23:21 +00:00
|
|
|
{
|
2014-10-29 06:26:35 +00:00
|
|
|
// Reset checked status
|
|
|
|
currentNode.checked = false;
|
|
|
|
|
|
|
|
if (currentNode.validForInput(highestInputPriorityID, highestRenderOrderID, false))
|
2014-07-15 10:20:43 +00:00
|
|
|
{
|
|
|
|
// Flag it as checked so we don't re-scan it on the next phase
|
|
|
|
currentNode.checked = true;
|
2013-09-08 21:38:19 +00:00
|
|
|
|
2014-10-29 06:26:35 +00:00
|
|
|
if ((fromClick && currentNode.checkPointerDown(this, true)) ||
|
|
|
|
(!fromClick && currentNode.checkPointerOver(this, true)))
|
2014-07-15 10:20:43 +00:00
|
|
|
{
|
2015-02-16 17:22:51 +00:00
|
|
|
highestRenderOrderID = currentNode.sprite.renderOrderID;
|
2014-10-29 06:26:35 +00:00
|
|
|
highestInputPriorityID = currentNode.priorityID;
|
|
|
|
candidateTarget = currentNode;
|
2014-07-15 10:20:43 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-29 06:26:35 +00:00
|
|
|
|
2014-07-15 10:20:43 +00:00
|
|
|
currentNode = this.game.input.interactiveItems.next;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then in the second sweep we process ONLY the pixel perfect ones that are checked and who have a higher ID
|
|
|
|
// because if their ID is lower anyway then we can just automatically discount them
|
2014-10-29 06:26:35 +00:00
|
|
|
// (A node that was previously checked did not request a pixel-perfect check.)
|
2014-07-15 10:20:43 +00:00
|
|
|
|
|
|
|
var currentNode = this.game.input.interactiveItems.first;
|
|
|
|
|
2015-09-22 12:53:19 +00:00
|
|
|
while (currentNode)
|
2014-07-15 10:20:43 +00:00
|
|
|
{
|
2014-10-29 06:26:35 +00:00
|
|
|
if (!currentNode.checked &&
|
|
|
|
currentNode.validForInput(highestInputPriorityID, highestRenderOrderID, true))
|
2013-09-08 12:23:21 +00:00
|
|
|
{
|
2014-10-29 06:26:35 +00:00
|
|
|
if ((fromClick && currentNode.checkPointerDown(this, false)) ||
|
|
|
|
(!fromClick && currentNode.checkPointerOver(this, false)))
|
2013-09-08 12:23:21 +00:00
|
|
|
{
|
2015-02-16 17:22:51 +00:00
|
|
|
highestRenderOrderID = currentNode.sprite.renderOrderID;
|
2014-10-29 06:26:35 +00:00
|
|
|
highestInputPriorityID = currentNode.priorityID;
|
|
|
|
candidateTarget = currentNode;
|
2013-09-08 12:23:21 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-29 06:26:35 +00:00
|
|
|
|
2014-07-15 10:20:43 +00:00
|
|
|
currentNode = this.game.input.interactiveItems.next;
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
2014-07-15 10:20:43 +00:00
|
|
|
|
|
|
|
// Now we know the top-most item (if any) we can process it
|
2014-10-29 06:26:35 +00:00
|
|
|
if (candidateTarget === null)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2013-09-08 16:39:23 +00:00
|
|
|
// The pointer isn't currently over anything, check if we've got a lingering previous target
|
|
|
|
if (this.targetObject)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2013-09-08 16:39:23 +00:00
|
|
|
this.targetObject._pointerOutHandler(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
this.targetObject = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-10 02:14:59 +00:00
|
|
|
if (this.targetObject === null)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
// And now set the new one
|
2014-10-29 06:26:35 +00:00
|
|
|
this.targetObject = candidateTarget;
|
|
|
|
candidateTarget._pointerOverHandler(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We've got a target from the last update
|
2014-10-29 06:26:35 +00:00
|
|
|
if (this.targetObject === candidateTarget)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
// Same target as before, so update it
|
2014-10-29 06:26:35 +00:00
|
|
|
if (candidateTarget.update(this) === false)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
this.targetObject = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The target has changed, so tell the old one we've left it
|
2013-09-08 16:39:23 +00:00
|
|
|
this.targetObject._pointerOutHandler(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
// And now set the new one
|
2014-10-29 06:26:35 +00:00
|
|
|
this.targetObject = candidateTarget;
|
2013-09-08 16:39:23 +00:00
|
|
|
this.targetObject._pointerOverHandler(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-27 20:24:53 +00:00
|
|
|
return (this.targetObject !== null);
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* Called when the Pointer leaves the target area.
|
2014-05-02 11:21:57 +00:00
|
|
|
*
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#leave
|
2013-11-25 03:13:04 +00:00
|
|
|
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
|
|
|
leave: function (event) {
|
|
|
|
|
|
|
|
this.withinGame = false;
|
2014-02-12 01:25:36 +00:00
|
|
|
this.move(event, false);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* Called when the Pointer leaves the touchscreen.
|
2014-05-02 11:21:57 +00:00
|
|
|
*
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#stop
|
2013-11-25 03:13:04 +00:00
|
|
|
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
|
|
|
stop: function (event) {
|
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
var input = this.game.input;
|
|
|
|
|
2015-02-11 16:03:24 +00:00
|
|
|
if (this._stateReset && this.withinGame)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
event.preventDefault();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-08 20:01:10 +00:00
|
|
|
this.timeUp = this.game.time.time;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
if (input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH ||
|
|
|
|
input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE ||
|
|
|
|
(input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0))
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
input.onUp.dispatch(this, event);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
// Was it a tap?
|
2015-09-29 15:06:44 +00:00
|
|
|
if (this.duration >= 0 && this.duration <= input.tapRate)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
// Was it a double-tap?
|
2015-09-29 15:06:44 +00:00
|
|
|
if (this.timeUp - this.previousTapTime < input.doubleTapRate)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
// Yes, let's dispatch the signal then with the 2nd parameter set to true
|
2015-09-29 15:06:44 +00:00
|
|
|
input.onTap.dispatch(this, true);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Wasn't a double-tap, so dispatch a single tap signal
|
2015-09-29 15:06:44 +00:00
|
|
|
input.onTap.dispatch(this, false);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.previousTapTime = this.timeUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-30 13:08:26 +00:00
|
|
|
if (this.isMouse)
|
|
|
|
{
|
|
|
|
this.updateButtons(event);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.isDown = false;
|
|
|
|
this.isUp = true;
|
|
|
|
}
|
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
// Mouse is always active
|
|
|
|
if (this.id > 0)
|
|
|
|
{
|
|
|
|
this.active = false;
|
|
|
|
}
|
|
|
|
|
2015-08-20 11:47:50 +00:00
|
|
|
this.withinGame = this.game.scale.bounds.contains(event.pageX, event.pageY);
|
2014-05-02 11:21:57 +00:00
|
|
|
this.pointerId = null;
|
|
|
|
this.identifier = null;
|
2014-03-31 14:07:19 +00:00
|
|
|
|
|
|
|
this.positionUp.setTo(this.x, this.y);
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
if (this.isMouse === false)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2015-09-29 15:06:44 +00:00
|
|
|
input.currentPointers--;
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
2015-09-29 15:06:44 +00:00
|
|
|
input.interactiveItems.callAll('_releasedHandler', this);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2014-11-01 08:04:17 +00:00
|
|
|
if (this._clickTrampolines)
|
|
|
|
{
|
|
|
|
this._trampolineTargetObject = this.targetObject;
|
|
|
|
}
|
2015-07-07 15:53:56 +00:00
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
this.targetObject = null;
|
2014-04-25 14:11:54 +00:00
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
return this;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate.
|
2013-11-25 03:13:04 +00:00
|
|
|
* Note that calling justPressed doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid.
|
|
|
|
* If you wish to check if the Pointer was pressed down just once then see the Sprite.events.onInputDown event.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#justPressed
|
2013-11-25 03:13:04 +00:00
|
|
|
* @param {number} [duration] - The time to check against. If none given it will use InputManager.justPressedRate.
|
|
|
|
* @return {boolean} true if the Pointer was pressed down within the duration given.
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
|
|
|
justPressed: function (duration) {
|
|
|
|
|
2013-09-08 16:39:23 +00:00
|
|
|
duration = duration || this.game.input.justPressedRate;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2014-11-08 20:01:10 +00:00
|
|
|
return (this.isDown === true && (this.timeDown + duration) > this.game.time.time);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate.
|
2013-11-25 03:13:04 +00:00
|
|
|
* Note that calling justReleased doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid.
|
|
|
|
* If you wish to check if the Pointer was released just once then see the Sprite.events.onInputUp event.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#justReleased
|
2013-11-25 03:13:04 +00:00
|
|
|
* @param {number} [duration] - The time to check against. If none given it will use InputManager.justReleasedRate.
|
|
|
|
* @return {boolean} true if the Pointer was released within the duration given.
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
|
|
|
justReleased: function (duration) {
|
|
|
|
|
2013-09-08 16:39:23 +00:00
|
|
|
duration = duration || this.game.input.justReleasedRate;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2015-07-12 10:56:25 +00:00
|
|
|
return (this.isUp && (this.timeUp + duration) > this.game.time.time);
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-11-01 08:04:17 +00:00
|
|
|
/**
|
|
|
|
* Add a click trampoline to this pointer.
|
|
|
|
*
|
|
|
|
* A click trampoline is a callback that is run on the DOM 'click' event; this is primarily
|
|
|
|
* needed with certain browsers (ie. IE11) which restrict some actions like requestFullscreen
|
2015-04-27 13:00:31 +00:00
|
|
|
* to the DOM 'click' event and rejects it for 'pointer*' and 'mouse*' events.
|
2014-11-01 08:04:17 +00:00
|
|
|
*
|
|
|
|
* This is used internally by the ScaleManager; click trampoline usage is uncommon.
|
2014-11-01 08:11:26 +00:00
|
|
|
* Click trampolines can only be added to pointers that are currently down.
|
2014-11-01 08:04:17 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Pointer#addClickTrampoline
|
|
|
|
* @protected
|
|
|
|
* @param {string} name - The name of the trampoline; must be unique among active trampolines in this pointer.
|
|
|
|
* @param {function} callback - Callback to run/trampoline.
|
|
|
|
* @param {object} callbackContext - Context of the callback.
|
|
|
|
* @param {object[]|null} callbackArgs - Additional callback args, if any. Supplied as an array.
|
|
|
|
*/
|
|
|
|
addClickTrampoline: function (name, callback, callbackContext, callbackArgs) {
|
|
|
|
|
|
|
|
if (!this.isDown)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var trampolines = (this._clickTrampolines = this._clickTrampolines || []);
|
|
|
|
|
2014-11-01 08:25:01 +00:00
|
|
|
for (var i = 0; i < trampolines.length; i++)
|
2014-11-01 08:04:17 +00:00
|
|
|
{
|
|
|
|
if (trampolines[i].name === name)
|
|
|
|
{
|
|
|
|
trampolines.splice(i, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trampolines.push({
|
|
|
|
name: name,
|
|
|
|
targetObject: this.targetObject,
|
|
|
|
callback: callback,
|
|
|
|
callbackContext: callbackContext,
|
|
|
|
callbackArgs: callbackArgs
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-04-27 13:00:31 +00:00
|
|
|
* Fire all click trampolines for which the pointers are still referring to the registered object.
|
2014-11-01 08:04:17 +00:00
|
|
|
* @method Phaser.Pointer#processClickTrampolines
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
processClickTrampolines: function () {
|
|
|
|
|
|
|
|
var trampolines = this._clickTrampolines;
|
2015-04-27 13:00:31 +00:00
|
|
|
|
2014-11-01 08:04:17 +00:00
|
|
|
if (!trampolines)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < trampolines.length; i++)
|
|
|
|
{
|
|
|
|
var trampoline = trampolines[i];
|
|
|
|
|
|
|
|
if (trampoline.targetObject === this._trampolineTargetObject)
|
|
|
|
{
|
|
|
|
trampoline.callback.apply(trampoline.callbackContext, trampoline.callbackArgs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._clickTrampolines = null;
|
|
|
|
this._trampolineTargetObject = null;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
2013-08-31 12:54:59 +00:00
|
|
|
* Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @method Phaser.Pointer#reset
|
2013-08-31 12:54:59 +00:00
|
|
|
*/
|
|
|
|
reset: function () {
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
if (this.isMouse === false)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
|
|
|
this.active = false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 11:14:05 +00:00
|
|
|
this.pointerId = null;
|
2013-08-31 12:54:59 +00:00
|
|
|
this.identifier = null;
|
2014-08-28 23:47:49 +00:00
|
|
|
this.dirty = false;
|
2013-08-31 12:54:59 +00:00
|
|
|
this.totalTouches = 0;
|
|
|
|
this._holdSent = false;
|
|
|
|
this._history.length = 0;
|
|
|
|
this._stateReset = true;
|
|
|
|
|
2015-07-07 15:53:56 +00:00
|
|
|
this.resetButtons();
|
|
|
|
|
2013-09-08 16:39:23 +00:00
|
|
|
if (this.targetObject)
|
2013-08-31 12:54:59 +00:00
|
|
|
{
|
2013-09-08 16:39:23 +00:00
|
|
|
this.targetObject._releasedHandler(this);
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.targetObject = null;
|
|
|
|
|
2014-05-17 09:27:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the movementX and movementY properties. Use in your update handler after retrieving the values.
|
|
|
|
* @method Phaser.Pointer#resetMovement
|
|
|
|
*/
|
|
|
|
resetMovement: function() {
|
2014-05-19 12:11:58 +00:00
|
|
|
|
2014-05-17 09:27:31 +00:00
|
|
|
this.movementX = 0;
|
|
|
|
this.movementY = 0;
|
2014-05-19 12:11:58 +00:00
|
|
|
|
2013-08-31 12:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-12-30 16:54:00 +00:00
|
|
|
Phaser.Pointer.prototype.constructor = Phaser.Pointer;
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2015-07-12 10:56:25 +00:00
|
|
|
* How long the Pointer has been depressed on the touchscreen or *any* of the mouse buttons have been held down.
|
|
|
|
* If not currently down it returns -1.
|
2015-07-17 12:52:09 +00:00
|
|
|
* If you need to test a specific mouse or pen button then access the buttons directly, i.e. `Pointer.rightButton.duration`.
|
2015-07-12 10:56:25 +00:00
|
|
|
*
|
2013-10-02 14:05:55 +00:00
|
|
|
* @name Phaser.Pointer#duration
|
2015-07-12 10:56:25 +00:00
|
|
|
* @property {number} duration
|
2013-10-02 14:05:55 +00:00
|
|
|
* @readonly
|
2013-10-01 12:54:29 +00:00
|
|
|
*/
|
2013-08-31 20:50:34 +00:00
|
|
|
Object.defineProperty(Phaser.Pointer.prototype, "duration", {
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
if (this.isUp)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-11-08 20:01:10 +00:00
|
|
|
return this.game.time.time - this.timeDown;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2013-09-11 12:21:07 +00:00
|
|
|
}
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 14:05:55 +00:00
|
|
|
* Gets the X value of this Pointer in world coordinates based on the world camera.
|
|
|
|
* @name Phaser.Pointer#worldX
|
2016-05-04 22:29:31 +00:00
|
|
|
* @property {number} worldX - The X value of this Pointer in world coordinates based on the world camera.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @readonly
|
|
|
|
*/
|
2013-08-31 20:50:34 +00:00
|
|
|
Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
return this.game.world.camera.x + this.x;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2013-09-11 12:21:07 +00:00
|
|
|
}
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-10-02 14:05:55 +00:00
|
|
|
* Gets the Y value of this Pointer in world coordinates based on the world camera.
|
|
|
|
* @name Phaser.Pointer#worldY
|
2016-05-04 22:29:31 +00:00
|
|
|
* @property {number} worldY - The Y value of this Pointer in world coordinates based on the world camera.
|
2013-10-02 14:05:55 +00:00
|
|
|
* @readonly
|
|
|
|
*/
|
2013-08-31 20:50:34 +00:00
|
|
|
Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
return this.game.world.camera.y + this.y;
|
2013-08-31 12:54:59 +00:00
|
|
|
|
2013-09-11 12:21:07 +00:00
|
|
|
}
|
2013-08-31 12:54:59 +00:00
|
|
|
|
|
|
|
});
|
2015-09-22 02:22:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumeration categorizing operational modes of pointers.
|
|
|
|
*
|
|
|
|
* PointerType values represent valid bitmasks.
|
|
|
|
* For example, a value representing both Mouse and Touch devices
|
|
|
|
* can be expressed as `PointerMode.CURSOR | PointerMode.CONTACT`.
|
|
|
|
*
|
|
|
|
* Values may be added for future mode categorizations.
|
|
|
|
* @class Phaser.PointerMode
|
|
|
|
*/
|
|
|
|
Phaser.PointerMode = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A 'CURSOR' is a pointer with a *passive cursor* such as a mouse, touchpad, watcom stylus, or even TV-control arrow-pad.
|
|
|
|
*
|
|
|
|
* It has the property that a cursor is passively moved without activating the input.
|
|
|
|
* This currently corresponds with {@link Phaser.Pointer#isMouse} property.
|
|
|
|
* @constant
|
|
|
|
*/
|
|
|
|
CURSOR: 1 << 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A 'CONTACT' pointer has an *active cursor* that only tracks movement when actived; notably this is a touch-style input.
|
|
|
|
* @constant
|
|
|
|
*/
|
|
|
|
CONTACT: 1 << 1
|
|
|
|
|
|
|
|
};
|