mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Interactive Objects inside of Containers would still fire their input events even if the Container (or any ancestor) was set to be invisible. Objects now check their ancestor tree during the input cull and now properly skip input events if not visible. Fix #3620
This commit is contained in:
parent
a804d7fc75
commit
719a2eedca
2 changed files with 45 additions and 1 deletions
|
@ -83,6 +83,7 @@
|
|||
* Fixed a method signature issue with the Animation component's `remove()` handler when `Animation`s are removed from the `AnimationManager`. This prevented removed animations from stopping correctly.
|
||||
* If you set Phaser to use a pre-existing Canvas element it is no longer re-added to the DOM (thanks @NQNStudios)
|
||||
* The `TweenManager.getTweensOf` method has been fixed to remove a potential endless loop should multiple targets be passed in to it (thanks @cyantree)
|
||||
* Interactive Objects inside of Containers would still fire their input events even if the Container (or any ancestor) was set to be invisible. Objects now check their ancestor tree during the input cull and now properly skip input events if not visible. Fix #3620 (thanks @NemoStein)
|
||||
|
||||
### Examples, Documentation and TypeScript
|
||||
|
||||
|
|
|
@ -914,6 +914,49 @@ var InputManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the given Game Object should be considered as a candidate for input or not.
|
||||
*
|
||||
* Checks if the Game Object has an input component that is enabled, that it will render,
|
||||
* and finally, if it has a parent, that the parent parent, or any ancestor, is visible or not.
|
||||
*
|
||||
* @method Phaser.Input.InputManager#inputCandidate
|
||||
* @private
|
||||
* @since 3.10.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test.
|
||||
*
|
||||
* @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`.
|
||||
*/
|
||||
inputCandidate: function (gameObject)
|
||||
{
|
||||
var input = gameObject.input;
|
||||
|
||||
if (!input || !input.enabled || !gameObject.willRender())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var visible = true;
|
||||
var parent = gameObject.parentContainer;
|
||||
|
||||
if (parent)
|
||||
{
|
||||
do {
|
||||
if (!parent.visible)
|
||||
{
|
||||
visible = false;
|
||||
break;
|
||||
}
|
||||
|
||||
parent = parent.parentContainer;
|
||||
|
||||
} while (parent);
|
||||
}
|
||||
|
||||
return visible;
|
||||
},
|
||||
|
||||
/**
|
||||
* Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects.
|
||||
*
|
||||
|
@ -970,7 +1013,7 @@ var InputManager = new Class({
|
|||
{
|
||||
var gameObject = culledGameObjects[i];
|
||||
|
||||
if (!gameObject.input || !gameObject.input.enabled || !gameObject.willRender())
|
||||
if (!this.inputCandidate(gameObject))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue