The x position of the Camera, relative to the top-left of the game canvas.
The y position of the Camera, relative to the top-left of the game canvas.
The width of the Camera, in pixels.
The height of the Camera, in pixels.
The Camera alpha value. Setting this property impacts every single object that this Camera
renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out,
or via the chainable setAlpha method instead.
The alpha value starting from the bottom-left of the Game Object. This value is interpolated from the corner to the center of the Game Object.
The alpha value starting from the bottom-right of the Game Object. This value is interpolated from the corner to the center of the Game Object.
The alpha value starting from the top-left of the Game Object. This value is interpolated from the corner to the center of the Game Object.
The alpha value starting from the top-right of the Game Object. This value is interpolated from the corner to the center of the Game Object.
The background color of this Camera. Only used if transparent is false.
A reference to the Scene's Camera Manager to which this Camera belongs.
ReadonlycenterThe horizontal position of the center of the Camera's viewport, relative to the left of the game canvas.
ReadonlycenterThe vertical position of the center of the Camera's viewport, relative to the top of the game canvas.
The Camera dead zone.
The deadzone is only used when the camera is following a target.
It defines a rectangular region within which if the target is present, the camera will not scroll. If the target moves outside of this area, the camera will begin scrolling in order to follow it.
The lerp values that you can set for a follower target also apply when using a deadzone.
You can directly set this property to be an instance of a Rectangle. Or, you can use the
setDeadzone method for a chainable approach.
The rectangle you provide can have its dimensions adjusted dynamically, however, please note that its position is updated every frame, as it is constantly re-centered on the cameras mid point.
Calling setDeadzone with no arguments will reset an active deadzone, as will setting this property
to null.
Is this Camera dirty?
A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame.
This flag is cleared during rendering with the new values.
Should the camera cull Game Objects before checking them for input hit tests? In some special cases it may be beneficial to disable this.
ReadonlydisplayThe displayed height of the camera viewport, factoring in the camera zoom level.
If a camera has a viewport height of 600 and a zoom of 0.5 then its display height would be 1200, as it's displaying twice as many pixels as zoom level 1.
Equally, a camera with a height of 600 and zoom of 2 would have a display height of 300 pixels.
ReadonlydisplayThe displayed width of the camera viewport, factoring in the camera zoom level.
If a camera has a viewport width of 800 and a zoom of 0.5 then its display width would be 1600, as it's displaying twice as many pixels as zoom level 1.
Equally, a camera with a width of 800 and zoom of 2 would have a display width of 400 pixels.
The Camera Fade effect handler.
To fade this camera see the Camera.fade methods.
The filters for this camera. Filters control special effects and masks.
This object contains two lists of filters: internal and external.
See Phaser.GameObjects.Components.FilterList for more information.
The Camera Flash effect handler.
To flash this camera see the Camera.flash method.
The values stored in this property are subtracted from the Camera targets position, allowing you to
offset the camera from the actual target x/y coordinates by this amount.
Can also be set via setFollowOffset or as part of the startFollow call.
Whether to force the camera to render via a framebuffer.
This only applies when using the WebGL renderer.
This makes the camera contents available to other WebGL processes,
such as CaptureFrame.
The height of the Camera viewport, in pixels.
The viewport is the area into which the Camera renders. Setting the viewport does not restrict where the Camera can scroll to.
ReadonlyidThe Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. This value is a bitmask.
Does this Camera allow the Game Objects it renders to receive input events?
Is this Camera a Scene Camera? (which is the default), or a Camera belonging to a Texture?
The linear interpolation value to use when following a target.
Can also be set via setLerp or as part of the startFollow call.
The default values of 1 means the camera will instantly snap to the target coordinates. A lower value, such as 0.1 means the camera will more slowly track the target, giving a smooth transition. You can set the horizontal and vertical values independently, and also adjust this value in real-time during your game.
Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis.
The Mask this Camera is using during render.
Set the mask using the setMask method. Remove the mask using the clearMask method.
A local transform matrix combining matrix and matrixExternal.
A local transform matrix used to compute the camera location.
ReadonlymidThe mid-point of the Camera in 'world' coordinates.
Use it to obtain exactly where in the world the center of the camera is currently looking.
This value is updated in the preRender method, after the scroll values and follower have been processed.
The name of the Camera. This is left empty for your own use.
The horizontal origin of rotation for this Camera.
By default the camera rotates around the center of the viewport.
Changing the origin allows you to adjust the point in the viewport from which rotation happens. A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right.
See setOrigin to set both origins in a single, chainable call.
The vertical origin of rotation for this Camera.
By default the camera rotates around the center of the viewport.
Changing the origin allows you to adjust the point in the viewport from which rotation happens. A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right.
See setOrigin to set both origins in a single, chainable call.
The Camera Pan effect handler.
To pan this camera see the Camera.pan method.
This array is populated with all of the Game Objects that this Camera has rendered in the previous (or current, depending on when you inspect it) frame.
It is cleared at the start of Camera.preUpdate, or if the Camera is destroyed.
You should not modify this array as it is used internally by the input system, however you can read it as required. Note that Game Objects may appear in this list multiple times if they belong to multiple non-exclusive Containers.
ReadonlyrenderCan this Camera render rounded pixel values?
This property is updated during the preRender method and should not be
set directly. It is set based on the roundPixels property of the Camera
combined with the zoom level. If the zoom is an integer then the WebGL
Renderer can apply rounding during rendering.
The Camera Rotate To effect handler.
To rotate this camera see the Camera.rotateTo method.
Should this camera round its pixel values to integers?
A reference to the Game Scale Manager.
A reference to the Scene this camera belongs to.
A reference to the Game Scene Manager.
The horizontal scroll position of this Camera.
Change this value to cause the Camera to scroll around your Scene.
Alternatively, setting the Camera to follow a Game Object, via the startFollow method,
will automatically adjust the Camera scroll values accordingly.
You can set the bounds within which the Camera can scroll via the setBounds method.
The vertical scroll position of this Camera.
Change this value to cause the Camera to scroll around your Scene.
Alternatively, setting the Camera to follow a Game Object, via the startFollow method,
will automatically adjust the Camera scroll values accordingly.
You can set the bounds within which the Camera can scroll via the setBounds method.
The Camera Shake effect handler.
To shake this camera see the Camera.shake method.
Does this Camera have a transparent background?
Is this Camera using a bounds to restrict scrolling movement?
Set this property along with the bounds via Camera.setBounds.
Is this Camera visible or not?
A visible camera will render and perform input tests. An invisible camera will not render anything and will skip input tests.
The width of the Camera viewport, in pixels.
The viewport is the area into which the Camera renders. Setting the viewport does not restrict where the Camera can scroll to.
ReadonlyworldThe World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. You can use it for culling or intersection checks.
The x position of the Camera viewport, relative to the top-left of the game canvas.
The viewport is the area into which the camera renders.
To adjust the position the camera is looking at in the game world, see the scrollX value.
The y position of the Camera viewport, relative to the top-left of the game canvas.
The viewport is the area into which the camera renders.
To adjust the position the camera is looking at in the game world, see the scrollY value.
The Camera zoom value. Change this value to zoom in, or out of, a Scene.
A value of 0.5 would zoom the Camera out, so you can now see twice as much of the Scene as before. A value of 2 would zoom the Camera in, so every pixel now takes up 2 pixels when rendered.
Set to 1 to return to the default zoom level.
Be careful to never set this value to zero.
The Camera Zoom effect handler.
To zoom this camera see the Camera.zoom method.
The Camera horizontal zoom value. Change this value to zoom in, or out of, a Scene.
A value of 0.5 would zoom the Camera out, so you can now see twice as much of the Scene as before. A value of 2 would zoom the Camera in, so every pixel now takes up 2 pixels when rendered.
Set to 1 to return to the default zoom level.
Be careful to never set this value to zero.
The Camera vertical zoom value. Change this value to zoom in, or out of, a Scene.
A value of 0.5 would zoom the Camera out, so you can now see twice as much of the Scene as before. A value of 2 would zoom the Camera in, so every pixel now takes up 2 pixels when rendered.
Set to 1 to return to the default zoom level.
Be careful to never set this value to zero.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: anyThe context to invoke the listener with. Default this.
Adds the given Game Object to this cameras render list.
This is invoked during the rendering stage. Only objects that are actually rendered will appear in the render list.
The Game Object to add to the render list.
Moves the Camera so that it is centered on the given coordinates, bounds allowing.
The horizontal coordinate to center on.
The vertical coordinate to center on.
Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. Calling this does not change the scrollY value.
The horizontal coordinate to center on.
Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. Calling this does not change the scrollX value.
The vertical coordinate to center on.
Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled.
Moves the Camera so that it is re-centered based on its viewport size.
Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. Do not call this method if you are not using camera bounds.
The value to horizontally scroll clamp.
Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. Do not call this method if you are not using camera bounds.
The value to vertically scroll clamp.
Clears all alpha values associated with this Game Object.
Immediately sets the alpha levels back to 1 (fully opaque).
Clears the mask that this Camera was using.
OptionaldestroyMask: booleanDestroy the mask before clearing it? Default false.
Takes an array of Game Objects and returns a new array featuring only those objects visible by this camera.
An array of Game Objects to cull.
Destroys this Camera instance. You rarely need to call this directly.
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.
Calls each of the listeners registered for a given event.
The event name.
Additional arguments that will be passed to the event handler.
Return an array listing the events for which the emitter has registered listeners.
Fades the Camera from transparent to the given color over the duration specified.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalred: numberThe amount to fade the red channel towards. A value between 0 and 255. Default 0.
Optionalgreen: numberThe amount to fade the green channel towards. A value between 0 and 255. Default 0.
Optionalblue: numberThe amount to fade the blue channel towards. A value between 0 and 255. Default 0.
Optionalforce: booleanForce the effect to start immediately, even if already running. Default false.
Optionalcallback: FunctionThis 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.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Fades the Camera from the given color to transparent over the duration specified.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalred: numberThe amount to fade the red channel towards. A value between 0 and 255. Default 0.
Optionalgreen: numberThe amount to fade the green channel towards. A value between 0 and 255. Default 0.
Optionalblue: numberThe amount to fade the blue channel towards. A value between 0 and 255. Default 0.
Optionalforce: booleanForce the effect to start immediately, even if already running. Default false.
Optionalcallback: FunctionThis 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.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Fades the Camera in from the given color over the duration specified.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalred: numberThe amount to fade the red channel towards. A value between 0 and 255. Default 0.
Optionalgreen: numberThe amount to fade the green channel towards. A value between 0 and 255. Default 0.
Optionalblue: numberThe amount to fade the blue channel towards. A value between 0 and 255. Default 0.
Optionalcallback: FunctionThis 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.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Fades the Camera out to the given color over the duration specified. This is an alias for Camera.fade that forces the fade to start, regardless of existing fades.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalred: numberThe amount to fade the red channel towards. A value between 0 and 255. Default 0.
Optionalgreen: numberThe amount to fade the green channel towards. A value between 0 and 255. Default 0.
Optionalblue: numberThe amount to fade the blue channel towards. A value between 0 and 255. Default 0.
Optionalcallback: FunctionThis 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.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified.
Optionalduration: numberThe duration of the effect in milliseconds. Default 250.
Optionalred: numberThe amount to fade the red channel towards. A value between 0 and 255. Default 255.
Optionalgreen: numberThe amount to fade the green channel towards. A value between 0 and 255. Default 255.
Optionalblue: numberThe amount to fade the blue channel towards. A value between 0 and 255. Default 255.
Optionalforce: booleanForce the effect to start immediately, even if already running. Default false.
Optionalcallback: FunctionThis 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.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Returns the view matrix of the camera. This is used internally.
This is matrix if the camera is intended to render to a framebuffer,
and matrixCombined otherwise.
OptionalforceComposite: booleanIf true, the view matrix will always be matrix. This is typically used when rendering to a framebuffer, so the external matrix is irrelevant. Default false.
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.
The x position to convert to world space.
The y position to convert to world space.
Optionaloutput: OAn optional object to store the results in. If not provided a new Vector2 will be created.
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.
The Game Object, or array of Game Objects, to be ignored by this Camera.
Return the number of listeners listening to a given event.
The event name.
Return the listeners registered for a given event.
The event name.
Remove the listeners of a given event.
The event name.
Optionalfn: FunctionOnly remove the listeners that match this function.
Optionalcontext: anyOnly remove the listeners that have this context.
Optionalonce: booleanOnly remove one-time listeners.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: anyThe context to invoke the listener with. Default this.
Add a one-time listener for a given event.
The event name.
The listener function.
Optionalcontext: anyThe context to invoke the listener with. Default this.
This effect will scroll the Camera so that the center of its viewport finishes at the given destination, over the duration and with the ease specified.
The destination x coordinate to scroll the center of the Camera viewport to.
The destination y coordinate to scroll the center of the Camera viewport to.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalease: string | FunctionThe ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'.
Optionalforce: booleanForce the pan effect to start immediately, even if already running. Default false.
Optionalcallback: CameraPanCallbackThis callback will be invoked every frame for the duration of the effect. It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, the current camera scroll x coordinate and the current camera scroll y coordinate.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
ProtectedpreInternal preRender step.
Remove all listeners, or those of the specified event.
Optionalevent: string | symbolThe event name.
If this Camera has previously had movement bounds set on it, this will remove them.
Remove the listeners of a given event.
The event name.
Optionalfn: FunctionOnly remove the listeners that match this function.
Optionalcontext: anyOnly remove the listeners that have this context.
Optionalonce: booleanOnly remove one-time listeners.
Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to remove the fade.
Rotate the Camera to the given angle over the duration and with the ease specified.
The destination angle in radians to rotate the Camera view to.
OptionalshortestPath: booleanIf true, take the shortest distance to the destination. This adjusts the destination angle to be within one half turn of the start angle. Default false.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalease: string | FunctionThe ease to use. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'.
Optionalforce: booleanForce the rotation effect to start immediately, even if already running. Default false.
Optionalcallback: CameraRotateCallbackThis callback will be invoked every frame for the duration of the effect. It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, and the current camera rotation.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
Optionalvalue: numberThe Camera alpha value. Default 1.
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.
Optionalvalue: numberThe cameras angle of rotation, given in degrees. Default 0.
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.
Optionalcolor: string | number | InputColorObjectThe color value. In CSS, hex or numeric color notation. Default 'rgba(0,0,0,0)'.
Set the bounds of the Camera. The bounds are an axis-aligned rectangle.
The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the edges and into blank space. It does not limit the placement of Game Objects, or where the Camera viewport can be positioned.
Temporarily disable the bounds by changing the boolean Camera.useBounds.
Clear the bounds entirely by calling Camera.removeBounds.
If you set bounds that are smaller than the viewport it will stop the Camera from being able to scroll. The bounds can be positioned where-ever you wish. By default they are from 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of the Camera bounds. However, you can position them anywhere. So if you wanted a game world that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y to be -1024, -1024, with a width and height of 2048. Depending on your game you may find it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle.
The top-left x coordinate of the bounds.
The top-left y coordinate of the bounds.
The width of the bounds, in pixels.
The height of the bounds, in pixels.
OptionalcenterOn: booleanIf true the Camera will automatically be centered on the new bounds. Default false.
Sets the Camera dead zone.
The deadzone is only used when the camera is following a target.
It defines a rectangular region within which if the target is present, the camera will not scroll. If the target moves outside of this area, the camera will begin scrolling in order to follow it.
The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point of the camera. This allows you to use the object for additional game related checks, such as testing if an object is within it or not via a Rectangle.contains call.
The lerp values that you can set for a follower target also apply when using a deadzone.
Calling this method with no arguments will reset an active deadzone.
Optionalwidth: numberThe width of the deadzone rectangle in pixels. If not specified the deadzone is removed.
Optionalheight: numberThe height of the deadzone rectangle in pixels.
Sets the horizontal and vertical offset of the camera from its follow target. The values are subtracted from the targets position during the Cameras update step.
Optionalx: numberThe horizontal offset from the camera follow target.x position. Default 0.
Optionaly: numberThe vertical offset from the camera follow target.y position. Default 0.
Sets the forceComposite property of this Camera.
This property is only used by the WebGL Renderer.
If true the camera will render via a framebuffer,
making it available to other WebGL systems.
The value to set the property to.
Set if this Camera is being used as a Scene Camera, or a Texture Camera.
Is this being used as a Scene Camera, or a Texture camera?
Sets the linear interpolation value to use when following a target.
The default values of 1 means the camera will instantly snap to the target coordinates. A lower value, such as 0.1 means the camera will more slowly track the target, giving a smooth transition. You can set the horizontal and vertical values independently, and also adjust this value in real-time during your game.
Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis.
Optionalx: numberThe amount added to the horizontal linear interpolation of the follow target. Default 1.
Optionaly: numberThe amount added to the vertical linear interpolation of the follow target. Default 1.
Sets the mask to be applied to this Camera during rendering.
The mask must have been previously created and must be a GeometryMask. This only works in the Canvas Renderer. In WebGL, use a Mask filter instead (see Phaser.GameObjects.Components.FilterList#addMask).
If a mask is already set on this Camera it will be immediately replaced.
Masks have no impact on physics or input detection. They are purely a rendering component that allows you to limit what is visible during the render pass.
The mask this Camera will use when rendering.
OptionalfixedPosition: booleanShould the mask translate along with the Camera, or be fixed in place and not impacted by the Cameras transform? Default true.
Sets the name of this Camera. This value is for your own use and isn't used internally.
Optionalvalue: stringThe name of the Camera. Default ''.
Sets the rotation origin of this Camera.
The values are given in the range 0 to 1 and are only used when calculating Camera rotation.
By default the camera rotates around the center of the viewport.
Changing the origin allows you to adjust the point in the viewport from which rotation happens. A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right.
Optionalx: numberThe horizontal origin value. Default 0.5.
Optionaly: numberThe vertical origin value. If not defined it will be set to the value of x. Default x.
Set the position of the Camera viewport within the game.
This does not change where the camera is 'looking'. See setScroll to control that.
The top-left x coordinate of the Camera viewport.
Optionaly: numberThe top-left y coordinate of the Camera viewport. Default x.
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.
Optionalvalue: numberThe rotation of the Camera, in radians. Default 0.
Should the Camera round pixel values to whole integers when rendering Game Objects?
In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing.
true to round Camera pixels, false to not.
Sets the Scene the Camera is bound to.
The Scene the camera is bound to.
OptionalisSceneCamera: booleanIs this Camera being used for a Scene (true) or a Texture? (false) Default true.
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.
The x coordinate of the Camera in the game world.
Optionaly: numberThe y coordinate of the Camera in the game world. Default x.
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.
The width of the Camera viewport.
Optionalheight: numberThe height of the Camera viewport. Default width.
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.
The top-left x coordinate of the Camera viewport.
The top-left y coordinate of the Camera viewport.
The width of the Camera viewport.
Optionalheight: numberThe height of the Camera viewport. Default width.
Sets the visibility of this Camera.
An invisible Camera will skip rendering and input tests of everything it can see.
The visible state of the Camera.
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.
As of Phaser 3.50 you can now set the horizontal and vertical zoom values independently.
Optionalx: numberThe horizontal zoom value of the Camera. The minimum it can be is 0.001. Default 1.
Optionaly: numberThe vertical zoom value of the Camera. The minimum it can be is 0.001. Default x.
Shakes the Camera by the given intensity over the duration specified.
Optionalduration: numberThe duration of the effect in milliseconds. Default 100.
Optionalintensity: number | Math.Vector2The intensity of the shake. Default 0.05.
Optionalforce: booleanForce the shake effect to start immediately, even if already running. Default false.
Optionalcallback: FunctionThis 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.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
Removes all listeners.
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.
You can set the linear interpolation value used in the follow code. Use low lerp values (such as 0.1) to automatically smooth the camera motion.
If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel
rendering of the targets position. This can be rounded by setting the roundPixels argument to true to
force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom
value on the camera. So be sure to keep the camera zoom to integers.
The target for the Camera to follow.
OptionalroundPixels: booleanRound the camera position to whole integers to avoid sub-pixel rendering? Default false.
OptionallerpX: numberA value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. Default 1.
OptionallerpY: numberA value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. Default 1.
OptionaloffsetX: numberThe horizontal offset from the camera follow target.x position. Default 0.
OptionaloffsetY: numberThe vertical offset from the camera follow target.y position. Default 0.
Stops a Camera from following a Game Object, if previously set via Camera.startFollow.
Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties.
ProtectedupdateInternal method called automatically by the Camera Manager.
The current timestamp as generated by the Request Animation Frame or SetTimeout.
The delta time, in ms, elapsed since the last frame.
This effect will zoom the Camera to the given scale, over the duration and with the ease specified.
The target Camera zoom value.
Optionalduration: numberThe duration of the effect in milliseconds. Default 1000.
Optionalease: string | FunctionThe ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'.
Optionalforce: booleanForce the pan effect to start immediately, even if already running. Default false.
Optionalcallback: CameraPanCallbackThis callback will be invoked every frame for the duration of the effect. It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, the current camera scroll x coordinate and the current camera scroll y coordinate.
Optionalcontext: anyThe context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.
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
setViewportandsetSize).If you wish to change where the Camera is looking in your game, then you scroll it. You can do this via the properties
scrollXandscrollYor the methodsetScroll. 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
ignoremethod, 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.