Merge pull request #5839 from natureofcode/fix/issue-5828

Fix #5828, improve GameObject#disableInteractive() and InputPlugin#disable()
This commit is contained in:
Richard Davey 2021-12-01 17:46:34 +00:00 committed by GitHub
commit 385800ec2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 5 deletions

View file

@ -504,10 +504,7 @@ var GameObject = new Class({
*/
disableInteractive: function ()
{
if (this.input)
{
this.input.enabled = false;
}
this.scene.sys.input.disable(this);
return this;
},

View file

@ -838,7 +838,44 @@ var InputPlugin = new Class({
*/
disable: function (gameObject)
{
gameObject.input.enabled = false;
var input = gameObject.input;
if (!input)
{
return this;
}
input.enabled = false;
input.dragState = 0;
// Clear from _temp, _drag and _over
var index = this._temp.indexOf(gameObject);
if (index > -1)
{
this._temp.splice(index, 1);
}
for (var i = 0; i < 10; i++)
{
index = this._drag[i].indexOf(gameObject);
if (index > -1)
{
this._drag[i].splice(index, 1);
}
index = this._over[i].indexOf(gameObject);
if (index > -1)
{
this._over[i].splice(index, 1);
this.manager.resetCursor(input);
}
}
return this;
},
/**