Skip to content

Commit e20d4b1

Browse files
committed
Now possible to clear interactive objects.
1 parent d2f08f0 commit e20d4b1

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

v3/src/gameobjects/GameObject.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ var GameObject = new Class({
8484
{
8585
this.parent.remove(this);
8686

87+
if (this.input)
88+
{
89+
this.scene.sys.inputManager.clear(this);
90+
}
91+
8792
this.scene = undefined;
8893
}
8994

v3/src/input/local/SceneInputManager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ var SceneInputManager = new Class({
7878

7979
boot: require('./components/Boot'),
8080
begin: require('./components/Begin'),
81+
clear: require('./components/Clear'),
8182
update: require('./components/Update'),
8283
hitTestPointer: require('./components/HitTestPointer'),
8384
disable: require('./components/Disable'),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ var Begin = function ()
2525
{
2626
current.splice(index, 1);
2727

28-
// TODO: Tidy up all of the Interactive Objects references, callbacks, shapes, etc
29-
gameObject.input = null;
28+
// TODO: Clear from _draggable, _drag and _over too
29+
30+
this.clear(gameObject);
3031
}
3132
}
3233

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var Clear = function (gameObject)
2+
{
3+
var input = gameObject.input;
4+
5+
input.gameObject = undefined;
6+
input.target = undefined;
7+
input.hitArea = undefined;
8+
input.hitAreaCallback = undefined;
9+
input.callbackContext = undefined;
10+
11+
gameObject.input = null;
12+
13+
return gameObject;
14+
};
15+
16+
module.exports = Clear;

0 commit comments

Comments
 (0)