Completed all jsdocs for the Camera class

This commit is contained in:
Richard Davey 2018-04-15 05:05:03 +01:00
parent ae603240e1
commit e37b183038
6 changed files with 219 additions and 105 deletions

View file

@ -34,15 +34,28 @@ var Vector2 = require('../../math/Vector2');
* @property {number} [bounds.height] - The height of the bounds of camera * @property {number} [bounds.height] - The height of the bounds of camera
*/ */
/**
* @callback Camera2DCallback
*
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
/** /**
* @classdesc * @classdesc
* [description] * A Camera.
*
* The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world,
* and can be positioned, rotated, zoomed and scrolled accordingly.
*
* A Camera consists of two elements: The viewport and the scroll values.
*
* The viewport is the physical position and size of the Camera within your game. Cameras, by default, are
* created the same size as your game, but their position and size can be set to anything. This means if you
* wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game,
* you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`).
*
* If you wish to change where the Camera is looking in your game, then you scroll it. You can do this
* via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the
* 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.
*
* A Camera also has built-in special effects including Fade, Flash and Camera Shake.
* *
* @class Camera * @class Camera
* @extends Phaser.Events.EventEmitter * @extends Phaser.Events.EventEmitter
@ -232,12 +245,35 @@ var Camera = new Class({
*/ */
this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); this.backgroundColor = ValueToColor('rgba(0,0,0,0)');
// Allow to be modified /**
this.effects = { * The Camera Fade effect handler.
fade: new Effects.Fade(this), * To fade this camera see the `Camera.fade` methods.
flash: new Effects.Flash(this), *
shake: new Effects.Shake(this) * @name Phaser.Cameras.Scene2D.Camera#fadeEffect
}; * @type {Phaser.Cameras.Scene2D.Effects.Fade}
* @since 3.5.0
*/
this.fadeEffect = new Effects.Fade(this);
/**
* The Camera Flash effect handler.
* To flash this camera see the `Camera.flash` method.
*
* @name Phaser.Cameras.Scene2D.Camera#flashEffect
* @type {Phaser.Cameras.Scene2D.Effects.Flash}
* @since 3.5.0
*/
this.flashEffect = new Effects.Flash(this);
/**
* The Camera Shake effect handler.
* To shake this camera see the `Camera.shake` method.
*
* @name Phaser.Cameras.Scene2D.Camera#shakeEffect
* @type {Phaser.Cameras.Scene2D.Effects.Shake}
* @since 3.5.0
*/
this.shakeEffect = new Effects.Shake(this);
/** /**
* Should the camera cull Game Objects before checking them for input hit tests? * Should the camera cull Game Objects before checking them for input hit tests?
@ -261,7 +297,7 @@ var Camera = new Class({
this.culledObjects = []; this.culledObjects = [];
/** /**
* [description] * Internal follow target reference.
* *
* @name Phaser.Cameras.Scene2D.Camera#_follow * @name Phaser.Cameras.Scene2D.Camera#_follow
* @type {?any} * @type {?any}
@ -272,7 +308,7 @@ var Camera = new Class({
this._follow = null; this._follow = null;
/** /**
* [description] * Internal camera ID. Assigned by the Camera Manager and used in the camera pool.
* *
* @name Phaser.Cameras.Scene2D.Camera#_id * @name Phaser.Cameras.Scene2D.Camera#_id
* @type {integer} * @type {integer}
@ -284,7 +320,7 @@ var Camera = new Class({
}, },
/** /**
* [description] * Scrolls the Camera so that it is looking at the center of the Camera Bounds (if previously enabled)
* *
* @method Phaser.Cameras.Scene2D.Camera#centerToBounds * @method Phaser.Cameras.Scene2D.Camera#centerToBounds
* @since 3.0.0 * @since 3.0.0
@ -292,15 +328,18 @@ var Camera = new Class({
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
centerToBounds: function () centerToBounds: function ()
{
if (this.useBounds)
{ {
this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5);
this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5);
}
return this; return this;
}, },
/** /**
* [description] * Scrolls the Camera so that it is re-centered based on its viewport size.
* *
* @method Phaser.Cameras.Scene2D.Camera#centerToSize * @method Phaser.Cameras.Scene2D.Camera#centerToSize
* @since 3.0.0 * @since 3.0.0
@ -316,16 +355,17 @@ var Camera = new Class({
}, },
/** /**
* [description] * Takes an array of Game Objects and returns a new array featuring only those objects
* visible by this camera.
* *
* @method Phaser.Cameras.Scene2D.Camera#cull * @method Phaser.Cameras.Scene2D.Camera#cull
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return]
* *
* @param {Phaser.GameObjects.GameObject[]} renderableObjects - [description] * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull.
* *
* @return {Phaser.GameObjects.GameObject[]} [description] * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera.
*/ */
cull: function (renderableObjects) cull: function (renderableObjects)
{ {
@ -412,7 +452,7 @@ var Camera = new Class({
*/ */
fadeIn: function (duration, red, green, blue, callback, context) fadeIn: function (duration, red, green, blue, callback, context)
{ {
return this.effects.fade.start(false, duration, red, green, blue, true, callback, context); return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context);
}, },
/** /**
@ -434,7 +474,7 @@ var Camera = new Class({
*/ */
fadeOut: function (duration, red, green, blue, callback, context) fadeOut: function (duration, red, green, blue, callback, context)
{ {
return this.effects.fade.start(true, duration, red, green, blue, true, callback, context); return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context);
}, },
/** /**
@ -456,7 +496,7 @@ var Camera = new Class({
*/ */
fadeFrom: function (duration, red, green, blue, force, callback, context) fadeFrom: function (duration, red, green, blue, force, callback, context)
{ {
return this.effects.fade.start(false, duration, red, green, blue, force, callback, context); return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context);
}, },
/** /**
@ -478,7 +518,7 @@ var Camera = new Class({
*/ */
fade: function (duration, red, green, blue, force, callback, context) fade: function (duration, red, green, blue, force, callback, context)
{ {
return this.effects.fade.start(true, duration, red, green, blue, force, callback, context); return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context);
}, },
/** /**
@ -500,7 +540,7 @@ var Camera = new Class({
*/ */
flash: function (duration, red, green, blue, force, callback, context) flash: function (duration, red, green, blue, force, callback, context)
{ {
return this.effects.flash.start(duration, red, green, blue, force, callback, context); return this.flashEffect.start(duration, red, green, blue, force, callback, context);
}, },
/** /**
@ -520,22 +560,23 @@ var Camera = new Class({
*/ */
shake: function (duration, intensity, force, callback, context) shake: function (duration, intensity, force, callback, context)
{ {
return this.effects.shake.start(duration, intensity, force, callback, context); return this.shakeEffect.start(duration, intensity, force, callback, context);
}, },
/** /**
* [description] * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform.
* You can optionally provide a Vector2, or similar object, to store the results in.
* *
* @method Phaser.Cameras.Scene2D.Camera#getWorldPoint * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Math.Vector2} O - [output,$return] * @generic {Phaser.Math.Vector2} O - [output,$return]
* *
* @param {number} x - [description] * @param {number} x - The x position to convert to world space.
* @param {number} y - [description] * @param {number} y - The y position to convert to world space.
* @param {(object|Phaser.Math.Vector2)} [output] - [description] * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created.
* *
* @return {Phaser.Math.Vector2} [description] * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties.
*/ */
getWorldPoint: function (x, y, output) getWorldPoint: function (x, y, output)
{ {
@ -589,41 +630,44 @@ var Camera = new Class({
}, },
/** /**
* [description] * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings
* so that they are ignored by this Camera. This means they will not be rendered by this Camera.
* *
* @method Phaser.Cameras.Scene2D.Camera#ignore * @method Phaser.Cameras.Scene2D.Camera#ignore
* @since 3.0.0 * @since 3.0.0
* *
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjectOrArray - [description] * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to be ignored by this Camera.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
ignore: function (gameObjectOrArray) ignore: function (gameObject)
{ {
if (Array.isArray(gameObjectOrArray)) var id = this._id;
if (Array.isArray(gameObject))
{ {
for (var index = 0; index < gameObjectOrArray.length; ++index) for (var i = 0; i < gameObject.length; i++)
{ {
gameObjectOrArray[index].cameraFilter |= this._id; gameObject[i].cameraFilter |= id;
} }
} }
else else
{ {
gameObjectOrArray.cameraFilter |= this._id; gameObject.cameraFilter |= id;
} }
return this; return this;
}, },
/** /**
* [description] * Internal preRender step.
* *
* @method Phaser.Cameras.Scene2D.Camera#preRender * @method Phaser.Cameras.Scene2D.Camera#preRender
* @protected
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} baseScale - [description] * @param {number} baseScale - The base scale, as set in the Camera Manager.
* @param {number} resolution - [description] * @param {number} resolution - The game resolution.
*
*/ */
preRender: function (baseScale, resolution) preRender: function (baseScale, resolution)
{ {
@ -683,11 +727,11 @@ var Camera = new Class({
matrix.scale(zoom, zoom); matrix.scale(zoom, zoom);
matrix.translate(-originX, -originY); matrix.translate(-originX, -originY);
this.effects.shake.preRender(); this.shakeEffect.preRender();
}, },
/** /**
* [description] * If this Camera has previously had movement bounds set on it, this will remove them.
* *
* @method Phaser.Cameras.Scene2D.Camera#removeBounds * @method Phaser.Cameras.Scene2D.Camera#removeBounds
* @since 3.0.0 * @since 3.0.0
@ -704,12 +748,14 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the rotation of this Camera. This causes everything it renders to appear rotated.
*
* Rotating a camera does not rotate the viewport itself, it is applied during rendering.
* *
* @method Phaser.Cameras.Scene2D.Camera#setAngle * @method Phaser.Cameras.Scene2D.Camera#setAngle
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} [value=0] - [description] * @param {number} [value=0] - The cameras angle of rotation, given in degrees.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -723,12 +769,17 @@ var Camera = new Class({
}, },
/** /**
* [description] * Sets the background color for this Camera.
*
* By default a Camera has a transparent background but it can be given a solid color, with any level
* of transparency, via this method.
*
* The color value can be specified using CSS color notation, hex or numbers.
* *
* @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor
* @since 3.0.0 * @since 3.0.0
* *
* @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - [description] * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -744,15 +795,18 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the world bounds for this Camera.
*
* A Camera bounds controls where the camera can scroll to within the world. It does not limit
* rendering of the camera, or placement of the viewport within your game.
* *
* @method Phaser.Cameras.Scene2D.Camera#setBounds * @method Phaser.Cameras.Scene2D.Camera#setBounds
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {integer} x - The top-left x coordinate of the bounds.
* @param {number} y - [description] * @param {integer} y - The top-left y coordinate of the bounds.
* @param {number} width - [description] * @param {integer} width - The width of the bounds, in pixels.
* @param {number} height - [description] * @param {integer} height - The height of the bounds, in pixels.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -766,12 +820,13 @@ var Camera = new Class({
}, },
/** /**
* [description] * Sets the name of this Camera.
* This value is for your own use and isn't used internally.
* *
* @method Phaser.Cameras.Scene2D.Camera#setName * @method Phaser.Cameras.Scene2D.Camera#setName
* @since 3.0.0 * @since 3.0.0
* *
* @param {string} [value=''] - [description] * @param {string} [value=''] - The name of the Camera.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -785,13 +840,15 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the position of the Camera viewport within the game.
*
* This does not change where the camera is 'looking'. See `setScroll` to control that.
* *
* @method Phaser.Cameras.Scene2D.Camera#setPosition * @method Phaser.Cameras.Scene2D.Camera#setPosition
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - The top-left x coordinate of the Camera viewport.
* @param {number} [y=x] - [description] * @param {number} [y=x] - The top-left y coordinate of the Camera viewport.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -806,12 +863,14 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the rotation of this Camera. This causes everything it renders to appear rotated.
*
* Rotating a camera does not rotate the viewport itself, it is applied during rendering.
* *
* @method Phaser.Cameras.Scene2D.Camera#setRotation * @method Phaser.Cameras.Scene2D.Camera#setRotation
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} [value=0] - [description] * @param {number} [value=0] - The rotation of the Camera, in radians.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -825,12 +884,13 @@ var Camera = new Class({
}, },
/** /**
* [description] * Should the Camera round pixel values to whole integers when scrolling?
* In some types of game this is required to prevent sub-pixel aliasing.
* *
* @method Phaser.Cameras.Scene2D.Camera#setRoundPixels * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels
* @since 3.0.0 * @since 3.0.0
* *
* @param {boolean} value - [description] * @param {boolean} value - `true` to round Camera pixels, `false` to not.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -842,12 +902,12 @@ var Camera = new Class({
}, },
/** /**
* [description] * Sets the Scene the Camera is bound to.
* *
* @method Phaser.Cameras.Scene2D.Camera#setScene * @method Phaser.Cameras.Scene2D.Camera#setScene
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Scene} scene - [description] * @param {Phaser.Scene} scene - The Scene the camera is bound to.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -859,13 +919,17 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the position of where the Camera is looking within the game.
* You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly.
* Use this method, or the scroll properties, to move your camera around the game world.
*
* This does not change where the camera viewport is placed. See `setPosition` to control that.
* *
* @method Phaser.Cameras.Scene2D.Camera#setScroll * @method Phaser.Cameras.Scene2D.Camera#setScroll
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - The x coordinate of the Camera in the game world.
* @param {number} [y=x] - [description] * @param {number} [y=x] - The y coordinate of the Camera in the game world.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -880,13 +944,17 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the size of the Camera viewport.
*
* By default a Camera is the same size as the game, but can be made smaller via this method,
* allowing you to create mini-cam style effects by creating and positioning a smaller Camera
* viewport within your game.
* *
* @method Phaser.Cameras.Scene2D.Camera#setSize * @method Phaser.Cameras.Scene2D.Camera#setSize
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} width - [description] * @param {integer} width - The width of the Camera viewport.
* @param {number} [height=width] - [description] * @param {integer} [height=width] - The height of the Camera viewport.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -901,15 +969,23 @@ var Camera = new Class({
}, },
/** /**
* [description] * This method sets the position and size of the Camera viewport in a single call.
*
* If you're trying to change where the Camera is looking at in your game, then see
* the method `Camera.setScroll` instead. This method is for changing the viewport
* itself, not what the camera can see.
*
* By default a Camera is the same size as the game, but can be made smaller via this method,
* allowing you to create mini-cam style effects by creating and positioning a smaller Camera
* viewport within your game.
* *
* @method Phaser.Cameras.Scene2D.Camera#setViewport * @method Phaser.Cameras.Scene2D.Camera#setViewport
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - The top-left x coordinate of the Camera viewport.
* @param {number} y - [description] * @param {number} y - The top-left y coordinate of the Camera viewport.
* @param {number} width - [description] * @param {integer} width - The width of the Camera viewport.
* @param {number} height - [description] * @param {integer} [height=width] - The height of the Camera viewport.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -924,12 +1000,19 @@ var Camera = new Class({
}, },
/** /**
* [description] * Set the zoom value of the Camera.
*
* Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'.
* Changing to a larger value, such as 2, will cause the camera to 'zoom in'.
*
* A value of 1 means 'no zoom' and is the default.
*
* Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering.
* *
* @method Phaser.Cameras.Scene2D.Camera#setZoom * @method Phaser.Cameras.Scene2D.Camera#setZoom
* @since 3.0.0 * @since 3.0.0
* *
* @param {float} [value=1] - [description] * @param {float} [value=1] - The zoom value of the Camera.
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -943,13 +1026,16 @@ var Camera = new Class({
}, },
/** /**
* [description] * Sets the Camera to follow a Game Object.
*
* When enabled the Camera will automatically adjust its scroll position to keep the target Game Object
* in its center.
* *
* @method Phaser.Cameras.Scene2D.Camera#startFollow * @method Phaser.Cameras.Scene2D.Camera#startFollow
* @since 3.0.0 * @since 3.0.0
* *
* @param {(Phaser.GameObjects.GameObject|object)} target - [description] * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow.
* @param {boolean} [roundPx=false] - [description] * @param {boolean} [roundPx=false] - Round the movement pixels to whole integers?
* *
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
*/ */
@ -965,7 +1051,7 @@ var Camera = new Class({
}, },
/** /**
* [description] * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`.
* *
* @method Phaser.Cameras.Scene2D.Camera#stopFollow * @method Phaser.Cameras.Scene2D.Camera#stopFollow
* @since 3.0.0 * @since 3.0.0
@ -980,12 +1066,12 @@ var Camera = new Class({
}, },
/** /**
* [description] * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties.
* *
* @method Phaser.Cameras.Scene2D.Camera#toJSON * @method Phaser.Cameras.Scene2D.Camera#toJSON
* @since 3.0.0 * @since 3.0.0
* *
* @return {JSONCamera} [description] * @return {JSONCamera} A well-formed object suitable for conversion to JSON.
*/ */
toJSON: function () toJSON: function ()
{ {
@ -1027,17 +1113,18 @@ var Camera = new Class({
*/ */
resetFX: function () resetFX: function ()
{ {
this.effects.shake.reset(); this.shakeEffect.reset();
this.effects.flash.reset(); this.flashEffect.reset();
this.effects.fade.reset(); this.fadeEffect.reset();
return this; return this;
}, },
/** /**
* [description] * Internal method called automatically by the Camera Manager.
* *
* @method Phaser.Cameras.Scene2D.Camera#update * @method Phaser.Cameras.Scene2D.Camera#update
* @protected
* @since 3.0.0 * @since 3.0.0
* *
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
@ -1045,9 +1132,9 @@ var Camera = new Class({
*/ */
update: function (time, delta) update: function (time, delta)
{ {
this.effects.shake.update(time, delta); this.shakeEffect.update(time, delta);
this.effects.flash.update(time, delta); this.flashEffect.update(time, delta);
this.effects.fade.update(time, delta); this.fadeEffect.update(time, delta);
}, },
/** /**
@ -1058,10 +1145,14 @@ var Camera = new Class({
*/ */
/** /**
* [description] * Destroys this Camera instance.
*
* Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as
* cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that.
* *
* @method Phaser.Cameras.Scene2D.Camera#destroy * @method Phaser.Cameras.Scene2D.Camera#destroy
* @fires CameraDestroyEvent * @fires CameraDestroyEvent
* @protected
* @since 3.0.0 * @since 3.0.0
*/ */
destroy: function () destroy: function ()
@ -1074,10 +1165,12 @@ var Camera = new Class({
this.matrix.destroy(); this.matrix.destroy();
this._bounds = undefined;
this.culledObjects = []; this.culledObjects = [];
this.target = undefined;
this._bounds = undefined;
this.scene = undefined; this.scene = undefined;
} }

View file

@ -152,11 +152,18 @@ var Fade = new Class({
*/ */
this._elapsed = 0; this._elapsed = 0;
/**
* @callback CameraFadeCallback
*
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running.
* @param {float} progress - The progress of the effect. A value between 0 and 1.
*/
/** /**
* This callback is invoked every frame for the duration of the effect. * This callback is invoked every frame for the duration of the effect.
* *
* @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdate * @name Phaser.Cameras.Scene2D.Effects.Fade#_onUpdate
* @type {?Camera2DCallback} * @type {?CameraFadeCallback}
* @private * @private
* @default null * @default null
* @since 3.5.0 * @since 3.5.0
@ -230,7 +237,7 @@ var Fade = new Class({
* @param {integer} [green=0] - The amount to fade the green channel towards. A value between 0 and 255. * @param {integer} [green=0] - The amount to fade the green channel towards. A value between 0 and 255.
* @param {integer} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {integer} [blue=0] - The amount to fade the blue channel towards. A value between 0 and 255.
* @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running.
* @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * @param {CameraFadeCallback} [callback] - This callback will be invoked every frame for the duration of the effect.
* It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is.
* @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
* *

View file

@ -127,11 +127,18 @@ var Flash = new Class({
*/ */
this._elapsed = 0; this._elapsed = 0;
/**
* @callback CameraFlashCallback
*
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running.
* @param {float} progress - The progress of the effect. A value between 0 and 1.
*/
/** /**
* This callback is invoked every frame for the duration of the effect. * This callback is invoked every frame for the duration of the effect.
* *
* @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdate * @name Phaser.Cameras.Scene2D.Effects.Flash#_onUpdate
* @type {?Camera2DCallback} * @type {?CameraFlashCallback}
* @private * @private
* @default null * @default null
* @since 3.5.0 * @since 3.5.0
@ -182,7 +189,7 @@ var Flash = new Class({
* @param {integer} [green=255] - The amount to fade the green channel towards. A value between 0 and 255. * @param {integer} [green=255] - The amount to fade the green channel towards. A value between 0 and 255.
* @param {integer} [blue=255] - The amount to fade the blue channel towards. A value between 0 and 255. * @param {integer} [blue=255] - The amount to fade the blue channel towards. A value between 0 and 255.
* @param {boolean} [force=false] - Force the effect to start immediately, even if already running. * @param {boolean} [force=false] - Force the effect to start immediately, even if already running.
* @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * @param {CameraFlashCallback} [callback] - This callback will be invoked every frame for the duration of the effect.
* It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is.
* @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
* *

View file

@ -117,11 +117,18 @@ var Shake = new Class({
*/ */
this._offsetY = 0; this._offsetY = 0;
/**
* @callback CameraShakeCallback
*
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running.
* @param {float} progress - The progress of the effect. A value between 0 and 1.
*/
/** /**
* This callback is invoked every frame for the duration of the effect. * This callback is invoked every frame for the duration of the effect.
* *
* @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdate * @name Phaser.Cameras.Scene2D.Effects.Shake#_onUpdate
* @type {?Camera2DCallback} * @type {?CameraShakeCallback}
* @private * @private
* @default null * @default null
* @since 3.5.0 * @since 3.5.0
@ -168,7 +175,7 @@ var Shake = new Class({
* @param {integer} [duration=100] - The duration of the effect in milliseconds. * @param {integer} [duration=100] - The duration of the effect in milliseconds.
* @param {number} [intensity=0.05] - The intensity of the shake. * @param {number} [intensity=0.05] - The intensity of the shake.
* @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running.
* @param {function} [callback] - This callback will be invoked every frame for the duration of the effect. * @param {CameraShakeCallback} [callback] - This callback will be invoked every frame for the duration of the effect.
* It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is.
* @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. * @param {any} [context] - The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
* *

View file

@ -443,8 +443,8 @@ var CanvasRenderer = new Class({
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.globalCompositeOperation = 'source-over'; ctx.globalCompositeOperation = 'source-over';
camera.effects.flash.postRenderCanvas(ctx); camera.flashEffect.postRenderCanvas(ctx);
camera.effects.fade.postRenderCanvas(ctx); camera.fadeEffect.postRenderCanvas(ctx);
// Reset the camera scissor // Reset the camera scissor
if (scissor) if (scissor)

View file

@ -1404,8 +1404,8 @@ var WebGLRenderer = new Class({
{ {
var FlatTintPipeline = this.pipelines.FlatTintPipeline; var FlatTintPipeline = this.pipelines.FlatTintPipeline;
var isFlashing = camera.effects.flash.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); var isFlashing = camera.flashEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats);
var isFading = camera.effects.fade.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); var isFading = camera.fadeEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats);
if (isFading || isFlashing) if (isFading || isFlashing)
{ {