Skip to content

Commit 8334826

Browse files
committed
Working through some topOnly debug tests
1 parent c7803e0 commit 8334826

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

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

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ var ProcessOverOutEvents = function (pointer)
1111
var stillOver = [];
1212
var previouslyOver = this._over[pointer.id];
1313

14-
// TODO - in a topOnly situation a new justOver entry at the top
15-
// should clear all previous justOut entries
16-
17-
// Go through all objects the pointer was previously over, and see if it still is
14+
// Go through all objects the pointer was previously over, and see if it still is.
15+
// Splits the previouslyOver array into two parts: justOut and stillOver
1816
for (i = 0; i < previouslyOver.length; i++)
1917
{
2018
gameObject = previouslyOver[i];
2119

2220
if (currentlyOver.indexOf(gameObject) === -1)
2321
{
24-
// Not in the currentlyOver array
22+
// Not in the currentlyOver array, so must be outside of this object now
2523
justOut.push(gameObject);
2624
}
2725
else
@@ -31,7 +29,8 @@ var ProcessOverOutEvents = function (pointer)
3129
}
3230
}
3331

34-
// Go through the hit test results
32+
// Go through the hit test results (the contents of currentlyOver)
33+
// and if not in the previouslyOver array we know it's a new entry, so add to justOver
3534
for (i = 0; i < currentlyOver.length; i++)
3635
{
3736
gameObject = currentlyOver[i];
@@ -46,11 +45,28 @@ var ProcessOverOutEvents = function (pointer)
4645

4746
// By this point the arrays are filled, so now we can process what happened...
4847

48+
// In a topOnly situation a new justOver entry at the top
49+
// should clear all previous justOut entries and ignore the rest of the stillOver entries
50+
51+
if (this.topOnly && justOver.length)
52+
{
53+
this.sortGameObjects(justOver);
54+
55+
// Only the top-most one counts now, ignore the rest
56+
var topObject = justOver.shift();
57+
58+
console.log('topOnly', topObject.name);
59+
60+
justOver = [ topObject ];
61+
62+
justOut = justOut.concat(stillOver);
63+
64+
stillOver.length = 0;
65+
}
66+
4967
// Process the Just Out objects
5068
var total = justOut.length;
5169

52-
console.log('justOut', total);
53-
5470
if (total > 0)
5571
{
5672
this.sortGameObjects(justOut);
@@ -70,20 +86,12 @@ var ProcessOverOutEvents = function (pointer)
7086
this.events.dispatch(new InputEvent.GAME_OBJECT_OUT(pointer, gameObject));
7187

7288
gameObject.input.onOut(gameObject, pointer);
73-
74-
if (this.topOnly)
75-
{
76-
console.log('break 1');
77-
break;
78-
}
7989
}
8090
}
8191

8292
// Process the Just Over objects
8393
total = justOver.length;
8494

85-
console.log('justOver', total);
86-
8795
if (total > 0)
8896
{
8997
this.sortGameObjects(justOver);
@@ -103,12 +111,6 @@ var ProcessOverOutEvents = function (pointer)
103111
this.events.dispatch(new InputEvent.GAME_OBJECT_OVER(pointer, gameObject));
104112

105113
gameObject.input.onOver(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
106-
107-
if (this.topOnly)
108-
{
109-
console.log('break 2');
110-
break;
111-
}
112114
}
113115
}
114116

0 commit comments

Comments
 (0)