Now possible to clear interactive objects.

This commit is contained in:
photonstorm 2017-07-28 01:17:18 +01:00
parent d2f08f0818
commit e20d4b1156
4 changed files with 25 additions and 2 deletions

View file

@ -84,6 +84,11 @@ var GameObject = new Class({
{
this.parent.remove(this);
if (this.input)
{
this.scene.sys.inputManager.clear(this);
}
this.scene = undefined;
}

View file

@ -78,6 +78,7 @@ var SceneInputManager = new Class({
boot: require('./components/Boot'),
begin: require('./components/Begin'),
clear: require('./components/Clear'),
update: require('./components/Update'),
hitTestPointer: require('./components/HitTestPointer'),
disable: require('./components/Disable'),

View file

@ -25,8 +25,9 @@ var Begin = function ()
{
current.splice(index, 1);
// TODO: Tidy up all of the Interactive Objects references, callbacks, shapes, etc
gameObject.input = null;
// TODO: Clear from _draggable, _drag and _over too
this.clear(gameObject);
}
}

View file

@ -0,0 +1,16 @@
var Clear = function (gameObject)
{
var input = gameObject.input;
input.gameObject = undefined;
input.target = undefined;
input.hitArea = undefined;
input.hitAreaCallback = undefined;
input.callbackContext = undefined;
gameObject.input = null;
return gameObject;
};
module.exports = Clear;