Skip to content

Commit 7041bd9

Browse files
committed
The InputManager.inputCandidate method, which determines if a Game Object can be interacted with by a given Pointer and Camera combination, now takes the full camera status into consideration. This means if a Camera is set to ignore a Game Object you can now longer interact with it, or if the Camera is ignoring a Container with an interactive Game Object inside it, you cannot interact with the Container children any more. Previously they would interact regardless of the Camera state. Fix phaserjs#3984
1 parent cbfc208 commit 7041bd9

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,13 @@ Setting the `resolution` property in the Game Config to a value other than 1 wou
239239
* A Game Object couldn't have a blend mode of `SKIP_TEST` set by using the getter or the `setBlendMode` method.
240240
* In Arcade Physics the `World.disable` call was passing the wrong argument, so never disabling the actual body (thanks @samme)
241241
* There was a visual bug with Rounded Rectangles in Canvas mode, due to the addition of the `overshoot` argument in the Graphics arc call. This has been fixed, so arcs will now render correctly and consistently in WebGL and Canvas and Rounded Rectangles are back to normal again too. Fix #3912 (thanks @valse)
242+
* The `InputManager.inputCandidate` method, which determines if a Game Object can be interacted with by a given Pointer and Camera combination, now takes the full camera status into consideration. This means if a Camera is set to ignore a Game Object you can now longer interact with it, or if the Camera is ignoring a Container with an interactive Game Object inside it, you cannot interact with the Container children any more. Previously they would interact regardless of the Camera state. Fix #3984 (thanks @NemoStein @samid737)
242243

243244
### Examples, Documentation and TypeScript
244245

245246
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
246247

247-
@SBCGames @rgk @rook2pawn @robbintt @bguyl @halilcakarr @PhaserEditor2D @Edwin222 @tfelix @Yudikubota @hexus @guzmonne @ampled @thanh-taro @dcbriccetti @Dreaded-Gnu @padme-amidala @rootasjey @ampled @thejonanshow @polarstoat @jdjoshuadavison @alexeymolchan @samme @PBird
248+
@SBCGames @rgk @rook2pawn @robbintt @bguyl @halilcakarr @PhaserEditor2D @Edwin222 @tfelix @Yudikubota @hexus @guzmonne @ampled @thanh-taro @dcbriccetti @Dreaded-Gnu @padme-amidala @rootasjey @ampled @thejonanshow @polarstoat @jdjoshuadavison @alexeymolchan @samme @PBird @spontoreau @hypertrifle
248249

249250
Thanks to @khaleb85 for fixing the super-annoying lag on the API Docs pages when it hung the browser while indexing the search field.
250251

src/input/InputManager.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,14 +1050,15 @@ var InputManager = new Class({
10501050
* @since 3.10.0
10511051
*
10521052
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test.
1053+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against.
10531054
*
10541055
* @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`.
10551056
*/
1056-
inputCandidate: function (gameObject)
1057+
inputCandidate: function (gameObject, camera)
10571058
{
10581059
var input = gameObject.input;
10591060

1060-
if (!input || !input.enabled || !gameObject.willRender())
1061+
if (!input || !input.enabled || !gameObject.willRender(camera))
10611062
{
10621063
return false;
10631064
}
@@ -1069,7 +1070,7 @@ var InputManager = new Class({
10691070
{
10701071
do
10711072
{
1072-
if (!parent.visible)
1073+
if (!parent.willRender(camera))
10731074
{
10741075
visible = false;
10751076
break;
@@ -1140,7 +1141,9 @@ var InputManager = new Class({
11401141
{
11411142
var gameObject = gameObjects[i];
11421143

1143-
if (!this.inputCandidate(gameObject))
1144+
// Checks if the Game Object can receive input (isn't being ignored by the camera, invisible, etc)
1145+
// and also checks all of its parents, if any
1146+
if (!this.inputCandidate(gameObject, camera))
11441147
{
11451148
continue;
11461149
}

0 commit comments

Comments
 (0)