CameraManager.getCameraBelowPointer has been renamed to getCamerasBelowPointer and it now returns an array of all the cameras below the given pointer, not just the top-most one. The array is sorted so that the top-most camera is at the start of the array.

This commit is contained in:
Richard Davey 2018-06-04 22:10:13 +01:00
parent 719a2eedca
commit bf2af95930

View file

@ -240,6 +240,7 @@ var CameraManager = new Class({
{ {
this.cameras.push(camera); this.cameras.push(camera);
this.cameraPool.slice(poolIndex, 1); this.cameraPool.slice(poolIndex, 1);
return camera; return camera;
} }
@ -284,6 +285,7 @@ var CameraManager = new Class({
camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0);
camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0);
camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false);
camera.visible = GetFastValue(cameraConfig, 'visible', true);
// Background Color // Background Color
@ -336,29 +338,38 @@ var CameraManager = new Class({
}, },
/** /**
* [description] * Returns an array of all cameras below the given Pointer.
*
* The first camera in the array is the top-most camera in the camera list.
* *
* @method Phaser.Cameras.Scene2D.CameraManager#getCameraBelowPointer * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer
* @since 3.0.0 * @since 3.10.0
* *
* @param {Phaser.Input.Pointer} pointer - [description] * @param {Phaser.Input.Pointer} pointer - The Pointer to check against.
* *
* @return {Phaser.Cameras.Scene2D.Camera} [description] * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer.
*/ */
getCameraBelowPointer: function (pointer) getCamerasBelowPointer: function (pointer)
{ {
var cameras = this.cameras; var cameras = this.cameras;
// Start from the most recently added camera (the 'top' camera) var x = pointer.x;
for (var i = cameras.length - 1; i >= 0; i--) var y = pointer.y;
var output = [];
for (var i = 0; i < cameras.length; i++)
{ {
var camera = cameras[i]; var camera = cameras[i];
if (camera.inputEnabled && RectangleContains(camera, pointer.x, pointer.y)) if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y))
{ {
return camera; // So the top-most camera is at the top of the search array
output.unshift(camera);
} }
} }
return output;
}, },
/** /**
@ -404,9 +415,12 @@ var CameraManager = new Class({
{ {
var camera = cameras[i]; var camera = cameras[i];
camera.preRender(baseScale, renderer.config.resolution); if (camera.visible)
{
camera.preRender(baseScale, renderer.config.resolution);
renderer.render(this.scene, children, interpolation, camera); renderer.render(this.scene, children, interpolation, camera);
}
} }
}, },