Skip to content

Commit 320a0b8

Browse files
committed
Preparing to normalize game object data
1 parent 466b0b1 commit 320a0b8

12 files changed

Lines changed: 57 additions & 29 deletions

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: '8c3fb080-70c2-11e7-b128-81fb6f2e39f6'
2+
build: 'be8a33d0-70d6-11e7-afe6-e9365652ea53'
33
};
44
module.exports = CHECKSUM;

v3/src/input/local/SceneInputManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ var SceneInputManager = new Class({
4242
// Internal counter
4343
this._pollTimer = 0;
4444

45+
// Used to temporarily store the results of the Hit Test
46+
this._temp = [];
47+
4548
// An object containing the various lists of Interactive Objects
46-
// list: A list of all Interactive Objects
49+
// list: A list of all Interactive Game Objects
4750
// pendingInsertion: Objects waiting to be inserted to the list on the next call to 'begin'
4851
// pendingRemoval: Objects waiting to be removed from the list on the next call to 'begin'
4952
// draggable: A list of all Interactive Objects that are set to be draggable (a subset of list)

v3/src/input/local/components/HitTestPointer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var HitTestPointer = function (pointer)
1+
var HitTestPointer = function (pointer, output)
22
{
3-
var output = [];
3+
output.length = 0;
44

55
// Get a list of all objects that can be seen by all the cameras in the scene and store in 'output' array.
66
// All objects in this array are input enabled, as checked by the hitTest function, so we don't need to check later on as well.

v3/src/input/local/components/ProcessDownEvents.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var InputEvent = require('../events');
22

3-
var ProcessDownEvents = function (pointer, currentlyOver)
3+
var ProcessDownEvents = function (pointer)
44
{
5-
this.events.dispatch(new InputEvent.POINTER_DOWN(pointer, currentlyOver));
5+
var currentlyOver = this._tempIO;
6+
7+
this.events.dispatch(new InputEvent.POINTER_DOWN(pointer, this._tempGO));
68

79
// Go through all objects the pointer was over and fire their events / callbacks
810
for (var i = 0; i < currentlyOver.length; i++)

v3/src/input/local/components/ProcessMoveEvents.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var InputEvent = require('../events');
22

3-
var ProcessMoveEvents = function (pointer, currentlyOver)
3+
var ProcessMoveEvents = function (pointer)
44
{
5-
this.events.dispatch(new InputEvent.POINTER_MOVE(pointer, currentlyOver));
5+
var currentlyOver = this._tempIO;
6+
7+
this.events.dispatch(new InputEvent.POINTER_MOVE(pointer, this._tempGO));
68

79
// Go through all objects the pointer was over and fire their events / callbacks
810
for (var i = 0; i < currentlyOver.length; i++)
@@ -14,7 +16,6 @@ var ProcessMoveEvents = function (pointer, currentlyOver)
1416
interactiveObject.onMove(interactiveObject.gameObject, pointer, interactiveObject.localX, interactiveObject.localY);
1517
}
1618

17-
1819
/*
1920
var i;
2021
var interactiveObject;

v3/src/input/local/components/ProcessOverOutEvents.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
var InputEvent = require('../events');
22

3-
var ProcessOverOutEvents = function (pointer, currentlyOver)
3+
var ProcessOverOutEvents = function (pointer)
44
{
5+
var currentlyOver = this._tempIO;
6+
57
var justOut = [];
68
var justOver = [];
79
var stillOver = [];

v3/src/input/local/components/ProcessUpEvents.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var InputEvent = require('../events');
22

3-
var ProcessUpEvents = function (pointer, currentlyOver)
3+
var ProcessUpEvents = function (pointer)
44
{
5-
this.events.dispatch(new InputEvent.POINTER_UP(pointer, currentlyOver));
5+
var currentlyOver = this._tempIO;
6+
7+
this.events.dispatch(new InputEvent.POINTER_UP(pointer, this._tempGO));
68

79
// Go through all objects the pointer was over and fire their events / callbacks
810
for (var i = 0; i < currentlyOver.length; i++)

v3/src/input/local/components/Update.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,40 @@ var Update = function (time, delta)
1919

2020
if (runUpdate)
2121
{
22-
var results = this.hitTestPointer(pointer);
22+
this.hitTestPointer(pointer, this._tempIO);
2323

24-
if (this.topOnly && results.length > 0)
24+
this.sortInteractiveObjects(this._tempIO);
25+
26+
if (this.topOnly && this._tempIO.length > 1)
2527
{
26-
this.sortInteractiveObjects(results);
28+
this._tempIO = this._tempIO.splice(1);
29+
}
2730

28-
var top = results[0];
31+
this._tempGO.length = 0;
2932

30-
results = [ top ];
33+
for (var i = 0; i < this._tempIO.length; i++)
34+
{
35+
this._tempGO.push(this._tempIO[i].gameObject);
3136
}
3237

33-
this.processOverOutEvents(pointer, results);
38+
// tempIO and tempGO now contain the sorted lists of InteractiveObjects
39+
// and their corresponding GameObjects
40+
41+
this.processOverOutEvents(pointer);
3442

3543
if (pointer.justUp)
3644
{
37-
this.processUpEvents(pointer, results);
45+
this.processUpEvents(pointer);
3846
}
3947

4048
if (pointer.justDown)
4149
{
42-
this.processDownEvents(pointer, results);
50+
this.processDownEvents(pointer);
4351
}
4452

4553
if (pointer.justMoved)
4654
{
47-
this.processMoveEvents(pointer, results);
55+
this.processMoveEvents(pointer);
4856
}
4957
}
5058
};

v3/src/input/local/events/PointerDownEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var PointerDownEvent = new Class({
3131
this.list = gameObjects;
3232

3333
// A reference to the top-most object on the display list (same as event.list[0])
34-
this.gameObject = gameObjects[0];
34+
this.gameObject = (gameObjects.length > 0) ? gameObjects[gameObjects.length - 1].gameObject : undefined;
3535
}
3636

3737
});

v3/src/input/local/events/PointerOutEvent.js

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

88
initialize:
99

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

@@ -25,10 +25,15 @@ var PointerOutEvent = new Class({
2525
// Will be undefined if no objects were interacted with.
2626
// If populated, the bottom element (list[0]) is the highest object on the display list.
2727
// If InputManager.topOnly is true this array will only contain one element.
28-
this.list = gameObjects;
28+
this.list = [];
29+
30+
for (var i = 0; i < interactiveObjects.length; i++)
31+
{
32+
this.list.push(interactiveObjects[i].gameObject);
33+
}
2934

3035
// A reference to the top-most object on the display list (also this.list[0])
31-
this.gameObject = gameObjects[0];
36+
this.gameObject = this.list[0];
3237
}
3338

3439
});

0 commit comments

Comments
 (0)