Skip to content

Commit 4466b3c

Browse files
committed
Input.getPointerFromIdentifier docs update to reflect where the identifier comes from. Pointer properties now set to give it fixed defaults (thanks @JirkaDellOro, phaserjs#793)
1 parent afc4f17 commit 4466b3c

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Version 2.0.5 - "Tanchico" - in development
5959

6060
### Updates
6161

62+
* TypeScript definitions fixes and updates (thanks @luispedrofonseca @clark-stevenson)
63+
* Input.getPointerFromIdentifier docs update to reflect where the identifier comes from. Pointer properties now set to give it fixed defaults (thanks @JirkaDellOro, #793)
64+
6265

6366

6467
### New Features
@@ -74,6 +77,8 @@ Version 2.0.5 - "Tanchico" - in development
7477
* Moved the this._reversed flag outside of the property loop in Tween (as per tween.js issue 115)
7578
* Emitter.makeParticles updated to use Array.isArray() check on the key/frame values, so non-string objects can be passed in (thanks @AnderbergE, fix #786)
7679
* Tilemap.createFromObjects will now force the creation of the property again even if it doesn't exist (regression fix from 2.0.4)
80+
* Phaser.Line.intersectsPoints fixed by properly checking the boundaries (thanks @woutercommandeur, fix #790)
81+
7782

7883

7984
P2.Body.collideWorldBounds = true fails.

src/input/Input.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,26 +672,29 @@ Phaser.Input.prototype = {
672672
},
673673

674674
/**
675-
* Get the Pointer object whos identified property matches the given identifier value.
675+
* Get the Pointer object whos `identifier` property matches the given identifier value.
676+
* The identifier property is not set until the Pointer has been used at least once, as its populated by the DOM event.
677+
* Also it can change every time you press the pointer down, and is not fixed once set.
678+
*
676679
* @method Phaser.Input#getPointerFromIdentifier
677680
* @param {number} identifier - The Pointer.identifier value to search for.
678681
* @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
679682
*/
680683
getPointerFromIdentifier: function (identifier) {
681684

682-
if (this.pointer1.identifier == identifier)
685+
if (this.pointer1.identifier === identifier)
683686
{
684687
return this.pointer1;
685688
}
686-
else if (this.pointer2.identifier == identifier)
689+
else if (this.pointer2.identifier === identifier)
687690
{
688691
return this.pointer2;
689692
}
690693
else
691694
{
692695
for (var i = 3; i <= 10; i++)
693696
{
694-
if (this['pointer' + i] && this['pointer' + i].identifier == identifier)
697+
if (this['pointer' + i] && this['pointer' + i].identifier === identifier)
695698
{
696699
return this['pointer' + i];
697700
}

src/input/Pointer.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ Phaser.Pointer = function (game, id) {
2525
*/
2626
this.id = id;
2727

28+
/**
29+
* @property {number} identifier - The identifier property of the Pointer as set by the DOM event when this Pointer is started.
30+
* @default
31+
*/
32+
this.identifier = 0;
33+
34+
/**
35+
* @property {any} target - The target property of the Pointer as set by the DOM event when this Pointer is started.
36+
* @default
37+
*/
38+
this.target = null;
39+
40+
/**
41+
* @property {any} button - The button property of the Pointer as set by the DOM event when this Pointer is started.
42+
* @default
43+
*/
44+
this.button = null;
45+
2846
/**
2947
* @property {boolean} _holdSent - Local private variable to store the status of dispatching a hold event.
3048
* @private
@@ -39,7 +57,7 @@ Phaser.Pointer = function (game, id) {
3957
this._history = [];
4058

4159
/**
42-
* @property {number} _lastDrop - Local private variable storing the time at which the next history drop should occur.
60+
* @property {number} _nextDrop - Local private variable storing the time at which the next history drop should occur.
4361
* @private
4462
* @default
4563
*/

0 commit comments

Comments
 (0)