Skip to content

Commit 8b7256c

Browse files
committed
Pointers now iterate the full camera list, starting at the top. Fix phaserjs#3631.
1 parent ccf50ff commit 8b7256c

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/input/InputPlugin.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ var InputPlugin = new Class({
535535
* it is currently above.
536536
*
537537
* The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple
538-
* cameras, the one on the top of the camera list is used.
538+
* cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list.
539539
*
540540
* @method Phaser.Input.InputPlugin#hitTestPointer
541541
* @since 3.0.0
@@ -546,11 +546,11 @@ var InputPlugin = new Class({
546546
*/
547547
hitTestPointer: function (pointer)
548548
{
549-
var camera = this.cameras.getCameraBelowPointer(pointer);
549+
var cameras = this.cameras.getCamerasBelowPointer(pointer);
550550

551-
if (camera)
551+
for (var c = 0; c < cameras.length; c++)
552552
{
553-
pointer.camera = camera;
553+
var camera = cameras[c];
554554

555555
// Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array.
556556
// All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well.
@@ -567,12 +567,15 @@ var InputPlugin = new Class({
567567
}
568568
}
569569

570-
return over;
571-
}
572-
else
573-
{
574-
return [];
570+
if (over.length > 0)
571+
{
572+
pointer.camera = camera;
573+
574+
return over;
575+
}
575576
}
577+
578+
return [];
576579
},
577580

578581
/**

0 commit comments

Comments
 (0)