mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Removed the cameraX properties because they fall out of sync on camera remove
This commit is contained in:
parent
da2b91b460
commit
f2b7fd0a32
2 changed files with 59 additions and 219 deletions
|
@ -9,7 +9,6 @@
|
|||
* `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game checks as needed.
|
||||
* `Camera.pan` is a new Camera Effect that allows you to control automatic camera pans between points in your game world. You can specify a duration and ease type for the pan, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the pan. See the examples and docs for more details.
|
||||
* `Camera.zoom` is a new Camera Effect that allows you to control automatic camera zooming. You can specify a duration and ease type for the zoom, as well as the zoom factor of course, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the zoom. Used in combination with the new Pan effect you can zoom and pan around with ease. See the examples and docs for more details.
|
||||
* The Camera Manager has 10 new read-only properties: `camera1`, `camera2` and so on, up to `camera10` so you can now quickly access the first 10 cameras created in the Camera Manager without needing to hold your own references too.
|
||||
* `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking.
|
||||
* `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level.
|
||||
* `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level.
|
||||
|
@ -17,10 +16,11 @@
|
|||
* The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski)
|
||||
* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree)
|
||||
* `Camera.setBounds` has a new optional argument `centerOn`. If specified it will automatically center the camera on the new bounds given.
|
||||
* The Camera will no longer stutter when following Game Objects at high zoom levels.
|
||||
* `Camera._id` has been renamed to `Camera.id`, a read-only bitmask used for camera exclusion from Game Objects.
|
||||
* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practise as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before.
|
||||
* `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera.
|
||||
* `CameraManager.currentCameraId` has been renamed to `nextID` and marked as read-only.
|
||||
* `CameraManager.currentCameraId` has been removed. IDs are assigned more intelligently now, via the `getNextID` internal method.
|
||||
* `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.
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ var RectangleContains = require('../../geom/rectangle/Contains');
|
|||
* By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed
|
||||
* in your game config.
|
||||
*
|
||||
* The Camera Manager can manage up to 31 unique Cameras. You can use the properties `camera1` through to `camera10`
|
||||
* for quick and easy access to the first 10 cameras you define.
|
||||
*
|
||||
* Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add
|
||||
* the new Camera in using the `addExisting` method.
|
||||
*
|
||||
|
@ -58,9 +55,12 @@ var RectangleContains = require('../../geom/rectangle/Contains');
|
|||
* viewport, and changing the viewport has no impact on the scrolling.
|
||||
*
|
||||
* By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method,
|
||||
* allowing you to filter Game Objects out on a per-Camera basis.
|
||||
* allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique
|
||||
* 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of
|
||||
* zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore
|
||||
* Game Objects, make sure it's one of the first 31 created.
|
||||
*
|
||||
* A Camera also has built-in special effects including Fade, Flash and Camera Shake.
|
||||
* A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom.
|
||||
*
|
||||
* @class CameraManager
|
||||
* @memberOf Phaser.Cameras.Scene2D
|
||||
|
@ -93,18 +93,6 @@ var CameraManager = new Class({
|
|||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
/**
|
||||
* The ID that will be assigned to the next Camera that is created.
|
||||
* This is a bitmask value, meaning only up to 31 cameras can be created in total.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#nextID
|
||||
* @type {integer}
|
||||
* @default 1
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.nextID = 1;
|
||||
|
||||
/**
|
||||
* An Array of the Camera objects being managed by this Camera Manager.
|
||||
* The Cameras are updated and rendered in the same order in which they appear in this array.
|
||||
|
@ -237,6 +225,8 @@ var CameraManager = new Class({
|
|||
camera.setName(name);
|
||||
camera.setScene(this.scene);
|
||||
|
||||
camera.id = this.getNextID();
|
||||
|
||||
this.cameras.push(camera);
|
||||
|
||||
if (makeMain)
|
||||
|
@ -244,13 +234,57 @@ var CameraManager = new Class({
|
|||
this.main = camera;
|
||||
}
|
||||
|
||||
camera.id = this.nextID;
|
||||
|
||||
this.nextID = this.nextID << 1;
|
||||
|
||||
return camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the next available Camera ID number.
|
||||
*
|
||||
* The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero.
|
||||
* You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#getNextID
|
||||
* @private
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @return {number} The next available Camera ID, or 0 if they're all already in use.
|
||||
*/
|
||||
getNextID: function ()
|
||||
{
|
||||
var cameras = this.cameras;
|
||||
|
||||
var testID = 1;
|
||||
|
||||
// Find the first free camera ID we can use
|
||||
|
||||
for (var t = 0; t < 32; t++)
|
||||
{
|
||||
var found = false;
|
||||
|
||||
for (var i = 0; i < cameras.length; i++)
|
||||
{
|
||||
var camera = cameras[i];
|
||||
|
||||
if (camera && camera.id === testID)
|
||||
{
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
testID = testID << 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return testID;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an existing Camera into the Camera Manager.
|
||||
*
|
||||
|
@ -277,12 +311,10 @@ var CameraManager = new Class({
|
|||
|
||||
if (index === -1)
|
||||
{
|
||||
camera.id = this.getNextID();
|
||||
|
||||
this.cameras.push(camera);
|
||||
|
||||
camera.id = this.nextID;
|
||||
|
||||
this.nextID = this.nextID << 1;
|
||||
|
||||
if (makeMain)
|
||||
{
|
||||
this.main = camera;
|
||||
|
@ -509,8 +541,6 @@ var CameraManager = new Class({
|
|||
|
||||
this.cameras = [];
|
||||
|
||||
this.nextID = 1;
|
||||
|
||||
this.main = this.add();
|
||||
|
||||
return this.main;
|
||||
|
@ -592,196 +622,6 @@ var CameraManager = new Class({
|
|||
|
||||
this.scene = null;
|
||||
this.systems = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 1 in the Camera Manager.
|
||||
*
|
||||
* Create additional cameras using the `add` method.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera1
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera1: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[0];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 2 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera2
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera2: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[1];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 3 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera3
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera3: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[2];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 4 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera4
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera4: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[3];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 5 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera5
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera5: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[4];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 6 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera6
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera6: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[5];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 7 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera7
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera7: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[6];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 8 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera8
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera8: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[7];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 9 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera9
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera9: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[8];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A reference to Camera 10 in the Camera Manager.
|
||||
*
|
||||
* This will be `undefined` by default unless you have created new cameras via `add` or `addExisting`.
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.CameraManager#camera10
|
||||
* @type {Phaser.Cameras.Scene2D.Camera}
|
||||
* @readOnly
|
||||
* @since 3.11.0
|
||||
*/
|
||||
camera10: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.cameras[9];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue