mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
remove can take an array of cameras and also no longer needs total to be > 0
This commit is contained in:
parent
183f5c4260
commit
1bfe58ab55
2 changed files with 21 additions and 8 deletions
|
@ -24,6 +24,8 @@
|
|||
* `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added.
|
||||
* `CameraManager.addExisting` has a new boolean argument `makeMain` which will make the new camera the main one.
|
||||
* `CameraManager.getTotal` is a new method that will return the total number of Cameras being managed, with an optional `isVisible` argument, that only counts visible cameras if set.
|
||||
* `CameraManager.remove` can now take an array of cameras to be removed from the manager, as well as a single camera.
|
||||
* `CameraManager.remove` would previously not allow you to remove a camera if it meant there would be no cameras left in the Camera Manager. This restriction has been removed. A Camera Manager can now run even with zero cameras. Your game obviously won't display anything, but it's still now possible.
|
||||
|
||||
### New Features
|
||||
|
||||
|
|
|
@ -492,7 +492,7 @@ var CameraManager = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Removes the given Camera from this Camera Manager.
|
||||
* Removes the given Camera, or an array of Cameras, from this Camera Manager.
|
||||
*
|
||||
* If found in the Camera Manager it will be immediately removed from the local cameras array.
|
||||
* If also currently the 'main' camera, 'main' will be reset to be camera 0.
|
||||
|
@ -503,21 +503,32 @@ var CameraManager = new Class({
|
|||
* @method Phaser.Cameras.Scene2D.CameraManager#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be removed from this Camera Manager.
|
||||
* @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager.
|
||||
*/
|
||||
remove: function (camera)
|
||||
{
|
||||
var cameraIndex = this.cameras.indexOf(camera);
|
||||
|
||||
if (cameraIndex >= 0 && this.cameras.length > 1)
|
||||
if (!Array.isArray(camera))
|
||||
{
|
||||
this.cameras.splice(cameraIndex, 1);
|
||||
camera = [ camera ];
|
||||
}
|
||||
|
||||
if (this.main === camera)
|
||||
var cameras = this.cameras;
|
||||
|
||||
for (var i = 0; i < camera.length; i++)
|
||||
{
|
||||
var index = cameras.indexOf(camera);
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
this.main = this.cameras[0];
|
||||
cameras.splice(index, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.main)
|
||||
{
|
||||
this.main = this.cameras[0];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue