Skip to content

Commit

Permalink
Updated function to use internal vars and fixed jsdoc. Also don't ret…
Browse files Browse the repository at this point in the history
…urn if input false, as object may still be in arrays anyway phaserjs#5839
  • Loading branch information
photonstorm committed Dec 1, 2021
1 parent 385800e commit a9538c0
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/input/InputPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,43 +835,48 @@ var InputPlugin = new Class({
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its input system disabled.
*
* @return {this} This Input Plugin.
*/
disable: function (gameObject)
{
var input = gameObject.input;

if (!input)
if (input)
{
return this;
input.enabled = false;
input.dragState = 0;
}

input.enabled = false;
input.dragState = 0;

// Clear from _temp, _drag and _over
var index = this._temp.indexOf(gameObject);
var temp = this._temp;
var drag = this._drag;
var over = this._over;
var manager = this.manager;

var index = temp.indexOf(gameObject);

if (index > -1)
{
this._temp.splice(index, 1);
temp.splice(index, 1);
}

for (var i = 0; i < 10; i++)
for (var i = 0; i < manager.pointersTotal; i++)
{
index = this._drag[i].indexOf(gameObject);
index = drag[i].indexOf(gameObject);

if (index > -1)
{
this._drag[i].splice(index, 1);
drag[i].splice(index, 1);
}

index = this._over[i].indexOf(gameObject);
index = over[i].indexOf(gameObject);

if (index > -1)
{
this._over[i].splice(index, 1);
over[i].splice(index, 1);

this.manager.resetCursor(input);
manager.resetCursor(input);
}
}

Expand Down

0 comments on commit a9538c0

Please sign in to comment.