Skip to content

Commit 669f2e8

Browse files
committed
Fixed callbacks not firing if an event nukes an interactive Game Object.
1 parent 757c9a0 commit 669f2e8

7 files changed

Lines changed: 60 additions & 9 deletions

File tree

v3/src/gameobjects/GameObject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ var GameObject = new Class({
220220
if (this.input)
221221
{
222222
this.scene.sys.inputManager.clear(this);
223+
this.input = undefined;
223224
}
224225

225226
if (this.body)
226227
{
227228
this.scene.sys.physicsManager.remove(this);
229+
this.body = undefined;
228230
}
229231

230232
this.active = false;

v3/src/input/global/inc/HitTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var HitTest = function (tempMatrix, x, y, gameObjects, camera, output)
2424
{
2525
var gameObject = culledGameObjects[i];
2626

27-
if (!gameObject.input.enabled || !gameObject.willRender())
27+
if (!gameObject.input || !gameObject.input.enabled || !gameObject.willRender())
2828
{
2929
continue;
3030
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ var ProcessDownEvents = function (pointer)
1111
{
1212
var gameObject = currentlyOver[i];
1313

14+
if (!gameObject.input)
15+
{
16+
continue;
17+
}
18+
1419
this.events.dispatch(new InputEvent.GAME_OBJECT_DOWN(pointer, gameObject));
1520

16-
gameObject.input.onDown(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
21+
if (gameObject.input)
22+
{
23+
gameObject.input.onDown(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
24+
}
1725

1826
if (this.topOnly)
1927
{

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ var ProcessDragEvents = function (pointer, time)
120120

121121
this.events.dispatch(new InputEvent.DRAG_START(pointer, gameObject));
122122

123-
input.onDragStart(gameObject, pointer, input.dragX, input.dragY);
123+
if (gameObject.input)
124+
{
125+
input.onDragStart(gameObject, pointer, input.dragX, input.dragY);
126+
}
124127
}
125128

126129
pointer.dragState = 4;
@@ -166,7 +169,10 @@ var ProcessDragEvents = function (pointer, time)
166169
// Still over it but it's no longer top of the display list (targets must always be at the top)
167170
this.events.dispatch(new InputEvent.DRAG_LEAVE(pointer, gameObject, input.target));
168171

169-
input.target = dropZones[0];
172+
if (gameObject.input)
173+
{
174+
input.target = dropZones[0];
175+
}
170176

171177
this.events.dispatch(new InputEvent.DRAG_ENTER(pointer, gameObject, input.target));
172178
}
@@ -234,7 +240,10 @@ var ProcessDragEvents = function (pointer, time)
234240

235241
this.events.dispatch(new InputEvent.DRAG_END(pointer, gameObject, dropped));
236242

237-
input.onDragEnd(gameObject, pointer, input.dragX, input.dragY);
243+
if (gameObject.input)
244+
{
245+
input.onDragEnd(gameObject, pointer, input.dragX, input.dragY);
246+
}
238247
}
239248

240249
pointer.dragState = 0;

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ var ProcessMoveEvents = function (pointer)
1111
{
1212
var gameObject = currentlyOver[i];
1313

14+
if (!gameObject.input)
15+
{
16+
continue;
17+
}
18+
1419
this.events.dispatch(new InputEvent.GAME_OBJECT_MOVE(pointer, gameObject));
1520

16-
gameObject.input.onMove(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
21+
if (gameObject.input)
22+
{
23+
gameObject.input.onMove(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
24+
}
1725

1826
if (this.topOnly)
1927
{

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,17 @@ var ProcessOverOutEvents = function (pointer)
5757
{
5858
gameObject = justOut[i];
5959

60+
if (!gameObject.input)
61+
{
62+
continue;
63+
}
64+
6065
this.events.dispatch(new InputEvent.GAME_OBJECT_OUT(pointer, gameObject));
6166

62-
gameObject.input.onOut(gameObject, pointer);
67+
if (gameObject.input)
68+
{
69+
gameObject.input.onOut(gameObject, pointer);
70+
}
6371

6472
if (this.topOnly)
6573
{
@@ -82,9 +90,17 @@ var ProcessOverOutEvents = function (pointer)
8290
{
8391
gameObject = justOver[i];
8492

93+
if (!gameObject.input)
94+
{
95+
continue;
96+
}
97+
8598
this.events.dispatch(new InputEvent.GAME_OBJECT_OVER(pointer, gameObject));
8699

87-
gameObject.input.onOver(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
100+
if (gameObject.input)
101+
{
102+
gameObject.input.onOver(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
103+
}
88104

89105
if (this.topOnly)
90106
{

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ var ProcessUpEvents = function (pointer)
1111
{
1212
var gameObject = currentlyOver[i];
1313

14+
if (!gameObject.input)
15+
{
16+
continue;
17+
}
18+
1419
this.events.dispatch(new InputEvent.GAME_OBJECT_UP(pointer, gameObject));
1520

16-
gameObject.input.onUp(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
21+
if (gameObject.input)
22+
{
23+
gameObject.input.onUp(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
24+
}
1725

1826
if (this.topOnly)
1927
{

0 commit comments

Comments
 (0)