Skip to content

Commit c848d18

Browse files
committed
Added processOptions config object to InputManager, allowing to set if all callbacks fire, or just that on the top of the display list. Added Input CONSTs. Updated Input Manager so events only fire once, carrying an array of all impacted GOs as a property.
1 parent 33258a2 commit c848d18

9 files changed

Lines changed: 170 additions & 43 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '98dca120-6d40-11e7-8ba2-2f8841c28191'
2+
build: '668ff4c0-6d49-11e7-a9ff-d120a05f4baf'
33
};
44
module.exports = CHECKSUM;

v3/src/input/const.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var INPUT_CONST = {
2+
3+
ALL: 0,
4+
TOP: 1
5+
6+
};
7+
8+
module.exports = INPUT_CONST;

v3/src/input/events/PointerDownEvent.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ var PointerDownEvent = new Class({
77

88
initialize:
99

10-
function PointerDownEvent (pointer, gameObject)
10+
function PointerDownEvent (pointer, topObject, gameObjects)
1111
{
1212
Event.call(this, 'POINTER_DOWN_EVENT');
1313

1414
this.pointer = pointer;
15-
this.gameObject = gameObject;
16-
this.input = gameObject.input;
1715

18-
this.x = gameObject.input.localX;
19-
this.y = gameObject.input.localY;
16+
this.x = pointer.x;
17+
this.y = pointer.y;
18+
19+
// An array of all the game objects the pointer event occurred on
20+
this.gameObjects = gameObjects;
21+
22+
// A reference to the top-most game object in the list (based on display list order)
23+
this.top = topObject;
2024
}
2125

2226
});

v3/src/input/events/PointerOutEvent.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ var PointerOutEvent = new Class({
77

88
initialize:
99

10-
function PointerOutEvent (pointer, gameObject)
10+
function PointerOutEvent (pointer, topObject, gameObjects)
1111
{
1212
Event.call(this, 'POINTER_OUT_EVENT');
1313

1414
this.pointer = pointer;
15-
this.gameObject = gameObject;
16-
this.input = gameObject.input;
1715

18-
this.x = gameObject.input.localX;
19-
this.y = gameObject.input.localY;
16+
this.x = pointer.x;
17+
this.y = pointer.y;
18+
19+
// An array of all the game objects the pointer event occurred on
20+
this.gameObjects = gameObjects;
21+
22+
// A reference to the top-most game object in the list (based on display list order)
23+
this.top = topObject;
2024
}
2125

2226
});

v3/src/input/events/PointerOverEvent.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ var PointerOverEvent = new Class({
77

88
initialize:
99

10-
function PointerOverEvent (pointer, gameObject)
10+
function PointerOverEvent (pointer, topObject, gameObjects)
1111
{
1212
Event.call(this, 'POINTER_OVER_EVENT');
1313

1414
this.pointer = pointer;
15-
this.gameObject = gameObject;
16-
this.input = gameObject.input;
1715

18-
this.x = gameObject.input.localX;
19-
this.y = gameObject.input.localY;
16+
this.x = pointer.x;
17+
this.y = pointer.y;
18+
19+
// An array of all the game objects the pointer event occurred on
20+
this.gameObjects = gameObjects;
21+
22+
// A reference to the top-most game object in the list (based on display list order)
23+
this.top = topObject;
2024
}
2125

2226
});

v3/src/input/events/PointerUpEvent.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ var PointerUpEvent = new Class({
77

88
initialize:
99

10-
function PointerUpEvent (pointer, gameObject)
10+
function PointerUpEvent (pointer, topObject, gameObjects)
1111
{
1212
Event.call(this, 'POINTER_UP_EVENT');
1313

1414
this.pointer = pointer;
15-
this.gameObject = gameObject;
16-
this.input = gameObject.input;
1715

18-
this.x = gameObject.input.localX;
19-
this.y = gameObject.input.localY;
16+
this.x = pointer.x;
17+
this.y = pointer.y;
18+
19+
// An array of all the game objects the pointer event occurred on
20+
this.gameObjects = gameObjects;
21+
22+
// A reference to the top-most game object in the list (based on display list order)
23+
this.top = topObject;
2024
}
2125

2226
});

v3/src/input/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
module.exports = {
44

5+
// CONSTs (makes them visible under Phaser.Input)
6+
RETURN_ALL: 0,
7+
RETURN_TOP: 1,
8+
59
Keyboard: require('./keyboard'),
610
Mouse: require('./mouse')
711

v3/src/plugins/DisplayList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ var DisplayList = new Class({
9494
return gameObjects.sort(this.sortIndexHandler.bind(this));
9595
},
9696

97+
// Note that the given array is sorted in place, even though it isn't returned directly it will still be updated.
9798
getTopGameObject: function (gameObjects)
9899
{
99100
this.sortGameObjects(gameObjects);

0 commit comments

Comments
 (0)