Phaser API Documentation

  Version: 
Filter

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.

Constructor:

new Camera(x, y, width, height)

Parameters:

name type description
x number

The x position of the Camera, relative to the top-left of the game canvas.

y number

The y position of the Camera, relative to the top-left of the game canvas.

width number

The width of the Camera, in pixels.

height number

The height of the Camera, in pixels.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 18)

Extends


Members

<private> _alpha: number
Focus
Focus

Description:

Private internal value. Holds the global alpha value.

Type:
number
Default: 1
Inherited from: Phaser.GameObjects.Components.Alpha#_alpha
Since: 3.0.0
Focus
Focus
<private> _alphaBL: number
Focus
Focus

Description:

Private internal value. Holds the bottom-left alpha value.

Type:
number
Default: 1
Inherited from: Phaser.GameObjects.Components.Alpha#_alphaBL
Since: 3.0.0
Focus
Focus
<private> _alphaBR: number
Focus
Focus

Description:

Private internal value. Holds the bottom-right alpha value.

Type:
number
Default: 1
Inherited from: Phaser.GameObjects.Components.Alpha#_alphaBR
Since: 3.0.0
Focus
Focus
<private> _alphaTL: number
Focus
Focus

Description:

Private internal value. Holds the top-left alpha value.

Type:
number
Default: 1
Inherited from: Phaser.GameObjects.Components.Alpha#_alphaTL
Since: 3.0.0
Focus
Focus
<private> _alphaTR: number
Focus
Focus

Description:

Private internal value. Holds the top-right alpha value.

Type:
number
Default: 1
Inherited from: Phaser.GameObjects.Components.Alpha#_alphaTR
Since: 3.0.0
Focus
Focus
<private> _bounds: Phaser.Geom.Rectangle
Focus
Focus

Description:

The bounds the camera is restrained to during scrolling.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_bounds
Since: 3.0.0
Focus
Focus
<private> _customViewport: boolean
Focus
Focus

Description:

Does this Camera have a custom viewport?

Type:
boolean
Default: false
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_customViewport
Since: 3.12.0
Focus
Focus
<private, nullable> _follow: any
Focus
Focus

Description:

Internal follow target reference.

Type:
any
Default: null
Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 199)
Focus
Focus
<private> _height: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_height
Since: 3.11.0
Focus
Focus
<private, nullable> _maskCamera: Phaser.Cameras.Scene2D.BaseCamera
Focus
Focus

Description:

The Camera that this Camera uses for translation during masking.

If the mask is fixed in position this will be a reference to the CameraManager.default instance. Otherwise, it'll be a reference to itself.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_maskCamera
Since: 3.17.0
Focus
Focus
<private> _rotation: number
Focus
Focus

Description:

The rotation of the Camera in radians.

Camera rotation always takes place based on the Camera viewport. By default, rotation happens in the center of the viewport. You can adjust this with the originX and originY properties.

Rotation influences the rendering of all Game Objects visible by this Camera. However, it does not rotate the Camera viewport itself, which always remains an axis-aligned rectangle.

Type:
number
Default: 0
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_rotation
Since: 3.11.0
Focus
Focus
<private> _scrollX: number
Focus
Focus

Description:

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.

Type:
number
Default: 0
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_scrollX
Since: 3.11.0
Focus
Focus
<private> _scrollY: number
Focus
Focus

Description:

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.

Type:
number
Default: 0
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_scrollY
Since: 3.11.0
Focus
Focus
<private> _visible: boolean
Focus
Focus

Description:

Private internal value. Holds the visible value.

Type:
boolean
Default: true
Inherited from: Phaser.GameObjects.Components.Visible#_visible
Since: 3.0.0
Focus
Focus
<private> _width: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_width
Since: 3.11.0
Focus
Focus
<private> _x: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_x
Since: 3.0.0
Focus
Focus
<private> _y: number
Focus
Focus

Description:

The y position of the Camera, 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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_y
Since: 3.0.0
Focus
Focus
<private> _zoomX: number
Focus
Focus

Description:

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.

Type:
number
Default: 1
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_zoomX
Since: 3.50.0
Focus
Focus
<private> _zoomY: number
Focus
Focus

Description:

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.

Type:
number
Default: 1
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#_zoomY
Since: 3.50.0
Focus
Focus
alpha: number
Focus
Focus

Description:

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.

Type:
number
Default: 1
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#alpha
Since: 3.11.0
Focus
Focus
Only webGL alphaBottomLeft: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.GameObjects.Components.Alpha#alphaBottomLeft
Since: 3.0.0
Focus
Focus
Only webGL alphaBottomRight: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.GameObjects.Components.Alpha#alphaBottomRight
Since: 3.0.0
Focus
Focus
Only webGL alphaTopLeft: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.GameObjects.Components.Alpha#alphaTopLeft
Since: 3.0.0
Focus
Focus
Only webGL alphaTopRight: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.GameObjects.Components.Alpha#alphaTopRight
Since: 3.0.0
Focus
Focus
backgroundColor: Phaser.Display.Color
Focus
Focus

Description:

The background color of this Camera. Only used if transparent is false.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#backgroundColor
Since: 3.0.0
Focus
Focus

Description:

A reference to the Scene's Camera Manager to which this Camera belongs.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#cameraManager
Since: 3.17.0
Focus
Focus
<readonly> centerX: number
Focus
Focus

Description:

The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerX
Since: 3.10.0
Focus
Focus
<readonly> centerY: number
Focus
Focus

Description:

The vertical position of the center of the Camera's viewport, relative to the top of the game canvas.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerY
Since: 3.10.0
Focus
Focus
<private> culledObjects: Array.<Phaser.GameObjects.GameObject>
Focus
Focus

Description:

A temporary array of culled objects.

Type:
Default: []
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#culledObjects
Since: 3.0.0
Focus
Focus
<nullable> deadzone: Phaser.Geom.Rectangle
Focus
Focus

Description:

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.

Type:
Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 174)
Focus
Focus
Only webGL defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline
Focus
Focus

Description:

The initial WebGL pipeline of this Game Object.

If you call resetPipeline on this Game Object, the pipeline is reset to this default.

Type:
Default: null
Inherited from: Phaser.GameObjects.Components.Pipeline#defaultPipeline
Since: 3.0.0
Focus
Focus
dirty: boolean
Focus
Focus

Description:

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 the postRenderCamera method of the renderer.

Type:
boolean
Default: true
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#dirty
Since: 3.11.0
Focus
Focus
disableCull: boolean
Focus
Focus

Description:

Should the camera cull Game Objects before checking them for input hit tests? In some special cases it may be beneficial to disable this.

Type:
boolean
Default: false
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#disableCull
Since: 3.0.0
Focus
Focus
<readonly> displayHeight: number
Focus
Focus

Description:

The 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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#displayHeight
Since: 3.11.0
Focus
Focus
<readonly> displayWidth: number
Focus
Focus

Description:

The 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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#displayWidth
Since: 3.11.0
Focus
Focus

Description:

The Camera Fade effect handler. To fade this camera see the Camera.fade methods.

Type:
Since: 3.5.0
Source: src/cameras/2d/Camera.js (Line 85)
Focus
Focus

Description:

The Camera Flash effect handler. To flash this camera see the Camera.flash method.

Type:
Since: 3.5.0
Source: src/cameras/2d/Camera.js (Line 95)
Focus
Focus
flipX: boolean
Focus
Focus

Description:

The horizontally flipped state of the Game Object.

A Game Object that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

Type:
boolean
Default: false
Inherited from: Phaser.GameObjects.Components.Flip#flipX
Since: 3.0.0
Focus
Focus
flipY: boolean
Focus
Focus

Description:

The vertically flipped state of the Game Object.

A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

Type:
boolean
Default: false
Inherited from: Phaser.GameObjects.Components.Flip#flipY
Since: 3.0.0
Focus
Focus
followOffset: Phaser.Math.Vector2
Focus
Focus

Description:

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.

Type:
Since: 3.9.0
Source: src/cameras/2d/Camera.js (Line 163)
Focus
Focus
Only webGL hasPostPipeline: boolean
Focus
Focus

Description:

Does this Game Object have any Post Pipelines set?

Type:
boolean
Inherited from: Phaser.GameObjects.Components.Pipeline#hasPostPipeline
Since: 3.50.0
Focus
Focus
height: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#height
Since: 3.0.0
Focus
Focus
<readonly> id: number
Focus
Focus

Description:

The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. This value is a bitmask.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#id
Since: 3.11.0
Focus
Focus
inputEnabled: boolean
Focus
Focus

Description:

Does this Camera allow the Game Objects it renders to receive input events?

Type:
boolean
Default: true
Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 75)
Focus
Focus
Only webGL <readonly> isTinted: boolean
Focus
Focus

Description:

Does this Game Object have a tint applied?

It checks to see if the 4 tint properties are set to the value 0xffffff and that the tintFill property is false. This indicates that a Game Object isn't tinted.

Type:
boolean
Inherited from: Phaser.GameObjects.Components.Tint#isTinted
Since: 3.11.0
Focus
Focus

Description:

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.

Type:
Since: 3.9.0
Source: src/cameras/2d/Camera.js (Line 145)
Focus
Focus

Description:

The Mask this Camera is using during render. Set the mask using the setMask method. Remove the mask using the clearMask method.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#mask
Since: 3.17.0
Focus
Focus

Description:

A local transform matrix used for internal calculations.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#matrix
Since: 3.0.0
Focus
Focus
<readonly> midPoint: Phaser.Math.Vector2
Focus
Focus

Description:

The 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.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#midPoint
Since: 3.11.0
Focus
Focus
name: string
Focus
Focus

Description:

The name of the Camera. This is left empty for your own use.

Type:
string
Default: ''
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#name
Since: 3.0.0
Focus
Focus
originX: number
Focus
Focus

Description:

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.

Type:
number
Default: 0.5
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#originX
Since: 3.11.0
Focus
Focus
originY: number
Focus
Focus

Description:

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.

Type:
number
Default: 0.5
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#originY
Since: 3.11.0
Focus
Focus

Description:

The Camera Pan effect handler. To pan this camera see the Camera.pan method.

Type:
Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 115)
Focus
Focus

Description:

The current WebGL pipeline of this Game Object.

Type:
Default: null
Inherited from: Phaser.GameObjects.Components.Pipeline#pipeline
Since: 3.0.0
Focus
Focus
Only webGL pipelineData: object
Focus
Focus

Description:

An object to store pipeline specific data in, to be read by the pipelines this Game Object uses.

Type:
object
Inherited from: Phaser.GameObjects.Components.Pipeline#pipelineData
Since: 3.50.0
Focus
Focus
Only webGL postPipelines: Array.<Phaser.Renderer.WebGL.Pipelines.PostFXPipeline>
Focus
Focus

Description:

The WebGL Post FX Pipelines this Game Object uses for post-render effects.

The pipelines are processed in the order in which they appear in this array.

If you modify this array directly, be sure to set the hasPostPipeline property accordingly.

Type:
Inherited from: Phaser.GameObjects.Components.Pipeline#postPipelines
Since: 3.50.0
Focus
Focus
renderList: Array.<Phaser.GameObjects.GameObject>
Focus
Focus

Description:

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.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#renderList
Since: 3.52.0
Focus
Focus

Description:

The Camera Rotate To effect handler. To rotate this camera see the Camera.rotateTo method.

Type:
Since: 3.23.0
Source: src/cameras/2d/Camera.js (Line 125)
Focus
Focus
<private> rotation: number
Focus
Focus

Description:

The rotation of the Camera in radians.

Camera rotation always takes place based on the Camera viewport. By default, rotation happens in the center of the viewport. You can adjust this with the originX and originY properties.

Rotation influences the rendering of all Game Objects visible by this Camera. However, it does not rotate the Camera viewport itself, which always remains an axis-aligned rectangle.

Type:
number
Default: 0
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#rotation
Since: 3.11.0
Focus
Focus
roundPixels: boolean
Focus
Focus

Description:

Should this camera round its pixel values to integers?

Type:
boolean
Default: false
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#roundPixels
Since: 3.0.0
Focus
Focus

Description:

A reference to the Game Scale Manager.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#scaleManager
Since: 3.16.0
Focus
Focus
scene: Phaser.Scene
Focus
Focus

Description:

A reference to the Scene this camera belongs to.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#scene
Since: 3.0.0
Focus
Focus

Description:

A reference to the Game Scene Manager.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#sceneManager
Since: 3.12.0
Focus
Focus
scrollX: number
Focus
Focus

Description:

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.

Type:
number
Default: 0
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#scrollX
Since: 3.0.0
Focus
Focus
scrollY: number
Focus
Focus

Description:

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.

Type:
number
Default: 0
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#scrollY
Since: 3.0.0
Focus
Focus

Description:

The Camera Shake effect handler. To shake this camera see the Camera.shake method.

Type:
Since: 3.5.0
Source: src/cameras/2d/Camera.js (Line 105)
Focus
Focus
Only webGL tint: number
Focus
Focus

Description:

The tint value being applied to the whole of the Game Object. This property is a setter-only. Use the properties tintTopLeft etc to read the current tint value.

Type:
number
Inherited from: Phaser.GameObjects.Components.Tint#tint
Since: 3.0.0
Focus
Focus
tintBottomLeft: number
Focus
Focus

Description:

The tint value being applied to the bottom-left vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.

Type:
number
Default: 0xffffff
Inherited from: Phaser.GameObjects.Components.Tint#tintBottomLeft
Since: 3.0.0
Focus
Focus
tintBottomRight: number
Focus
Focus

Description:

The tint value being applied to the bottom-right vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.

Type:
number
Default: 0xffffff
Inherited from: Phaser.GameObjects.Components.Tint#tintBottomRight
Since: 3.0.0
Focus
Focus
tintFill: boolean
Focus
Focus

Description:

The tint fill mode.

false = An additive tint (the default), where vertices colors are blended with the texture. true = A fill tint, where the vertices colors replace the texture, but respects texture alpha.

Type:
boolean
Default: false
Inherited from: Phaser.GameObjects.Components.Tint#tintFill
Since: 3.11.0
Focus
Focus
tintTopLeft: number
Focus
Focus

Description:

The tint value being applied to the top-left vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.

Type:
number
Default: 0xffffff
Inherited from: Phaser.GameObjects.Components.Tint#tintTopLeft
Since: 3.0.0
Focus
Focus
tintTopRight: number
Focus
Focus

Description:

The tint value being applied to the top-right vertice of the Game Object. This value is interpolated from the corner to the center of the Game Object. The value should be set as a hex number, i.e. 0xff0000 for red, or 0xff00ff for purple.

Type:
number
Default: 0xffffff
Inherited from: Phaser.GameObjects.Components.Tint#tintTopRight
Since: 3.0.0
Focus
Focus
transparent: boolean
Focus
Focus

Description:

Does this Camera have a transparent background?

Type:
boolean
Default: true
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#transparent
Since: 3.0.0
Focus
Focus
useBounds: boolean
Focus
Focus

Description:

Is this Camera using a bounds to restrict scrolling movement?

Set this property along with the bounds via Camera.setBounds.

Type:
boolean
Default: false
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#useBounds
Since: 3.0.0
Focus
Focus
visible: boolean
Focus
Focus

Description:

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.

Type:
boolean
Default: true
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#visible
Since: 3.10.0
Focus
Focus
width: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#width
Since: 3.0.0
Focus
Focus
<readonly> worldView: Phaser.Geom.Rectangle
Focus
Focus

Description:

The 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.

Type:
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#worldView
Since: 3.11.0
Focus
Focus
x: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#x
Since: 3.0.0
Focus
Focus
y: number
Focus
Focus

Description:

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.

Type:
number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#y
Since: 3.0.0
Focus
Focus
zoom: number
Focus
Focus

Description:

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.

Type:
number
Default: 1
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#zoom
Since: 3.0.0
Focus
Focus

Description:

The Camera Zoom effect handler. To zoom this camera see the Camera.zoom method.

Type:
Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 135)
Focus
Focus
zoomX: number
Focus
Focus

Description:

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.

Type:
number
Default: 1
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#zoomX
Since: 3.50.0
Focus
Focus
zoomY: number
Focus
Focus

Description:

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.

Type:
number
Default: 1
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#zoomY
Since: 3.50.0
Focus
Focus

Methods

addListener(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#addListener
Since: 3.0.0
Focus
Focus
addToRenderList(child)
Focus
Focus

Description:

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.

Parameters:

name type description
child Phaser.GameObjects.GameObject

The Game Object to add to the render list.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#addToRenderList
Since: 3.52.0
Focus
Focus
centerOn(x, y)
Focus
Focus

Description:

Moves the Camera so that it is centered on the given coordinates, bounds allowing.

Parameters:

name type description
x number

The horizontal coordinate to center on.

y number

The vertical coordinate to center on.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerOn
Since: 3.11.0
Focus
Focus
centerOnX(x)
Focus
Focus

Description:

Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. Calling this does not change the scrollY value.

Parameters:

name type description
x number

The horizontal coordinate to center on.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerOnX
Since: 3.16.0
Focus
Focus
centerOnY(y)
Focus
Focus

Description:

Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. Calling this does not change the scrollX value.

Parameters:

name type description
y number

The vertical coordinate to center on.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerOnY
Since: 3.16.0
Focus
Focus
centerToBounds()
Focus
Focus

Description:

Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerToBounds
Since: 3.0.0
Focus
Focus
centerToSize()
Focus
Focus

Description:

Moves the Camera so that it is re-centered based on its viewport size.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#centerToSize
Since: 3.0.0
Focus
Focus
clampX(x)
Focus
Focus

Description:

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.

Parameters:

name type description
x number

The value to horizontally scroll clamp.

Returns:
Description:

The adjusted value to use as scrollX.

Type:
  • number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#clampX
Since: 3.11.0
Focus
Focus
clampY(y)
Focus
Focus

Description:

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.

Parameters:

name type description
y number

The value to vertically scroll clamp.

Returns:
Description:

The adjusted value to use as scrollY.

Type:
  • number
Inherited from: Phaser.Cameras.Scene2D.BaseCamera#clampY
Since: 3.11.0
Focus
Focus
clearAlpha()
Focus
Focus

Description:

Clears all alpha values associated with this Game Object.

Immediately sets the alpha levels back to 1 (fully opaque).

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Alpha#clearAlpha
Since: 3.0.0
Focus
Focus
clearMask([destroyMask])
Focus
Focus

Description:

Clears the mask that this Camera was using.

Parameters:

name type arguments Default description
destroyMask boolean <optional> false

Destroy the mask before clearing it?

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#clearMask
Since: 3.17.0
Focus
Focus
Only webGL clearTint()
Focus
Focus

Description:

Clears all tint values associated with this Game Object.

Immediately sets the color values back to 0xffffff and the tint type to 'additive', which results in no visible change to the texture.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Tint#clearTint
Since: 3.0.0
Focus
Focus
cull(renderableObjects)
Focus
Focus

Description:

Takes an array of Game Objects and returns a new array featuring only those objects visible by this camera.

Parameters:

name type description
renderableObjects Array.<Phaser.GameObjects.GameObject>

An array of Game Objects to cull.

Returns:
Description:

An array of Game Objects visible to this Camera.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#cull
Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

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.

Overrides: Phaser.Cameras.Scene2D.BaseCamera#destroy
Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 782)
Focus
Focus
emit(event, [args])
Focus
Focus

Description:

Calls each of the listeners registered for a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

args * <optional>

Additional arguments that will be passed to the event handler.

Returns:
Description:

true if the event had listeners, else false.

Type:
  • boolean
Inherited from: Phaser.Events.EventEmitter#emit
Since: 3.0.0
Focus
Focus
eventNames()
Focus
Focus

Description:

Return an array listing the events for which the emitter has registered listeners.

Type:
  • Array.<(string
  • symbol)>
Inherited from: Phaser.Events.EventEmitter#eventNames
Since: 3.0.0
Focus
Focus
fade([duration], [red], [green], [blue], [force], [callback], [context])
Focus
Focus

Description:

Fades the Camera from transparent to the given color over the duration specified.

Parameters:

name type arguments Default description
duration number <optional> 1000

The duration of the effect in milliseconds.

red number <optional> 0

The amount to fade the red channel towards. A value between 0 and 255.

green number <optional> 0

The amount to fade the green channel towards. A value between 0 and 255.

blue number <optional> 0

The amount to fade the blue channel towards. A value between 0 and 255.

force boolean <optional> false

Force the effect to start immediately, even if already running.

callback function <optional>

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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 344)
Focus
Focus
fadeFrom([duration], [red], [green], [blue], [force], [callback], [context])
Focus
Focus

Description:

Fades the Camera from the given color to transparent over the duration specified.

Parameters:

name type arguments Default description
duration number <optional> 1000

The duration of the effect in milliseconds.

red number <optional> 0

The amount to fade the red channel towards. A value between 0 and 255.

green number <optional> 0

The amount to fade the green channel towards. A value between 0 and 255.

blue number <optional> 0

The amount to fade the blue channel towards. A value between 0 and 255.

force boolean <optional> false

Force the effect to start immediately, even if already running.

callback function <optional>

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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.5.0
Source: src/cameras/2d/Camera.js (Line 320)
Focus
Focus
fadeIn([duration], [red], [green], [blue], [callback], [context])
Focus
Focus

Description:

Fades the Camera in from the given color over the duration specified.

Parameters:

name type arguments Default description
duration number <optional> 1000

The duration of the effect in milliseconds.

red number <optional> 0

The amount to fade the red channel towards. A value between 0 and 255.

green number <optional> 0

The amount to fade the green channel towards. A value between 0 and 255.

blue number <optional> 0

The amount to fade the blue channel towards. A value between 0 and 255.

callback function <optional>

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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.3.0
Source: src/cameras/2d/Camera.js (Line 273)
Focus
Focus
fadeOut([duration], [red], [green], [blue], [callback], [context])
Focus
Focus

Description:

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.

Parameters:

name type arguments Default description
duration number <optional> 1000

The duration of the effect in milliseconds.

red number <optional> 0

The amount to fade the red channel towards. A value between 0 and 255.

green number <optional> 0

The amount to fade the green channel towards. A value between 0 and 255.

blue number <optional> 0

The amount to fade the blue channel towards. A value between 0 and 255.

callback function <optional>

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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.3.0
Source: src/cameras/2d/Camera.js (Line 296)
Focus
Focus
flash([duration], [red], [green], [blue], [force], [callback], [context])
Focus
Focus

Description:

Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified.

Parameters:

name type arguments Default description
duration number <optional> 250

The duration of the effect in milliseconds.

red number <optional> 255

The amount to fade the red channel towards. A value between 0 and 255.

green number <optional> 255

The amount to fade the green channel towards. A value between 0 and 255.

blue number <optional> 255

The amount to fade the blue channel towards. A value between 0 and 255.

force boolean <optional> false

Force the effect to start immediately, even if already running.

callback function <optional>

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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 368)
Focus
Focus
getBounds([out])
Focus
Focus

Description:

Returns a rectangle containing the bounds of the Camera.

If the Camera does not have any bounds the rectangle will be empty.

The rectangle is a copy of the bounds, so is safe to modify.

Parameters:

name type arguments description
out Phaser.Geom.Rectangle <optional>

An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created.

Returns:
Description:

A rectangle containing the bounds of this Camera.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#getBounds
Since: 3.16.0
Focus
Focus
Only webGL getPipelineName()
Focus
Focus

Description:

Gets the name of the WebGL Pipeline this Game Object is currently using.

Returns:
Description:

The string-based name of the pipeline being used by this Game Object.

Type:
  • string
Inherited from: Phaser.GameObjects.Components.Pipeline#getPipelineName
Since: 3.0.0
Focus
Focus
Only webGL getPostPipeline(pipeline)
Focus
Focus

Description:

Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it.

Parameters:

name type description
pipeline string | function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline

The string-based name of the pipeline, or a pipeline class.

Returns:
Description:

The Post Pipeline/s matching the name, or undefined if no match. If more than one match they are returned in an array.

Inherited from: Phaser.GameObjects.Components.Pipeline#getPostPipeline
Since: 3.50.0
Focus
Focus
getScroll(x, y, [out])
Focus
Focus

Description:

Calculates what the Camera.scrollX and scrollY values would need to be in order to move the Camera so it is centered on the given x and y coordinates, without actually moving the Camera there. The results are clamped based on the Camera bounds, if set.

Parameters:

name type arguments description
x number

The horizontal coordinate to center on.

y number

The vertical coordinate to center on.

out Phaser.Math.Vector2 <optional>

A Vector2 to store the values in. If not given a new Vector2 is created.

Returns:
Description:

The scroll coordinates stored in the x and y properties.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#getScroll
Since: 3.11.0
Focus
Focus
getWorldPoint(x, y, [output])
Focus
Focus

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.

Parameters:

name type arguments description
x number

The x position to convert to world space.

y number

The y position to convert to world space.

output object | Phaser.Math.Vector2 <optional>

An optional object to store the results in. If not provided a new Vector2 will be created.

Returns:
Description:

An object holding the converted values in its x and y properties.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint
Since: 3.0.0
Focus
Focus
ignore(entries)
Focus
Focus

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.

Parameters:

name type description
entries Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group

The Game Object, or array of Game Objects, to be ignored by this Camera.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#ignore
Since: 3.0.0
Focus
Focus
Only webGL initPipeline(pipeline)
Focus
Focus

Description:

Sets the initial WebGL Pipeline of this Game Object.

This should only be called during the instantiation of the Game Object. After that, use setPipeline.

Parameters:

name type description
pipeline string | Phaser.Renderer.WebGL.WebGLPipeline

Either the string-based name of the pipeline, or a pipeline instance to set.

Returns:
Description:

true if the pipeline was set successfully, otherwise false.

Type:
  • boolean
Inherited from: Phaser.GameObjects.Components.Pipeline#initPipeline
Since: 3.0.0
Focus
Focus
listenerCount(event)
Focus
Focus

Description:

Return the number of listeners listening to a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The number of listeners.

Type:
  • number
Inherited from: Phaser.Events.EventEmitter#listenerCount
Since: 3.0.0
Focus
Focus
listeners(event)
Focus
Focus

Description:

Return the listeners registered for a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The registered listeners.

Type:
  • Array.<function()>
Inherited from: Phaser.Events.EventEmitter#listeners
Since: 3.0.0
Focus
Focus
off(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#off
Since: 3.0.0
Focus
Focus
on(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#on
Since: 3.0.0
Focus
Focus
once(event, fn, [context])
Focus
Focus

Description:

Add a one-time listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#once
Since: 3.0.0
Focus
Focus
pan(x, y, [duration], [ease], [force], [callback], [context])
Focus
Focus

Description:

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.

Parameters:

name type arguments Default description
x number

The destination x coordinate to scroll the center of the Camera viewport to.

y number

The destination y coordinate to scroll the center of the Camera viewport to.

duration number <optional> 1000

The duration of the effect in milliseconds.

ease string | function <optional> 'Linear'

The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function.

force boolean <optional> false

Force the pan effect to start immediately, even if already running.

callback Phaser.Types.Cameras.Scene2D.CameraPanCallback <optional>

This 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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 414)
Focus
Focus
<protected> preRender()
Focus
Focus

Description:

Internal preRender step.

Overrides: Phaser.Cameras.Scene2D.BaseCamera#preRender
Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 488)
Focus
Focus
removeAllListeners([event])
Focus
Focus

Description:

Remove all listeners, or those of the specified event.

Parameters:

name type arguments description
event string | symbol <optional>

The event name.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeAllListeners
Since: 3.0.0
Focus
Focus
removeBounds()
Focus
Focus

Description:

If this Camera has previously had movement bounds set on it, this will remove them.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#removeBounds
Since: 3.0.0
Focus
Focus
removeListener(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeListener
Since: 3.0.0
Focus
Focus
Only webGL removePostPipeline(pipeline)
Focus
Focus

Description:

Removes a type of Post Pipeline instances from this Game Object, based on the given name, and destroys them.

If you wish to remove all Post Pipelines use the resetPostPipeline method instead.

Parameters:

name type description
pipeline string | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline

The string-based name of the pipeline, or a pipeline class.

Returns:
Description:

This Game Object.

Inherited from: Phaser.GameObjects.Components.Pipeline#removePostPipeline
Since: 3.50.0
Focus
Focus
resetFX()
Focus
Focus

Description:

Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to remove the fade.

Returns:
Description:

This Camera instance.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 739)
Focus
Focus
resetFlip()
Focus
Focus

Description:

Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Flip#resetFlip
Since: 3.0.0
Focus
Focus
Only webGL resetPipeline([resetPostPipelines], [resetData])
Focus
Focus

Description:

Resets the WebGL Pipeline of this Game Object back to the default it was created with.

Parameters:

name type arguments Default description
resetPostPipelines boolean <optional> false

Reset all of the post pipelines?

resetData boolean <optional> false

Reset the pipelineData object to being an empty object?

Returns:
Description:

true if the pipeline was reset successfully, otherwise false.

Type:
  • boolean
Inherited from: Phaser.GameObjects.Components.Pipeline#resetPipeline
Since: 3.0.0
Focus
Focus
Only webGL resetPostPipeline([resetData])
Focus
Focus

Description:

Resets the WebGL Post Pipelines of this Game Object. It does this by calling the destroy method on each post pipeline and then clearing the local array.

Parameters:

name type arguments Default description
resetData boolean <optional> false

Reset the pipelineData object to being an empty object?

Inherited from: Phaser.GameObjects.Components.Pipeline#resetPostPipeline
Since: 3.50.0
Focus
Focus
rotateTo(radians, [shortestPath], [duration], [ease], [force], [callback], [context])
Focus
Focus

Description:

This effect will rotate the Camera so that the viewport finishes at the given angle in radians, over the duration and with the ease specified.

Parameters:

name type arguments Default description
radians number

The destination angle in radians to rotate the Camera viewport to. If the angle is positive then the rotation is clockwise else anticlockwise

shortestPath boolean <optional> false

If shortest path is set to true the camera will rotate in the quickest direction clockwise or anti-clockwise.

duration number <optional> 1000

The duration of the effect in milliseconds.

ease string | function <optional> 'Linear'

The ease to use for the rotation. Can be any of the Phaser Easing constants or a custom function.

force boolean <optional> false

Force the rotation effect to start immediately, even if already running.

callback CameraRotateCallback <optional>

This 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 rotation angle in radians.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.23.0
Source: src/cameras/2d/Camera.js (Line 440)
Focus
Focus
setAlpha([value])
Focus
Focus

Description:

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.

Parameters:

name type arguments Default description
value number <optional> 1

The Camera alpha value.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setAlpha
Since: 3.11.0
Focus
Focus
setAngle([value])
Focus
Focus

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.

Parameters:

name type arguments description
value number <optional>

The cameras angle of rotation, given in degrees.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setAngle
Since: 3.0.0
Focus
Focus
setBackgroundColor([color])
Focus
Focus

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.

Parameters:

name type arguments Default description
color string | number | Phaser.Types.Display.InputColorObject <optional> 'rgba(0,0,0,0)'

The color value. In CSS, hex or numeric color notation.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor
Since: 3.0.0
Focus
Focus
setBounds(x, y, width, height, [centerOn])
Focus
Focus

Description:

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.

Parameters:

name type arguments Default description
x number

The top-left x coordinate of the bounds.

y number

The top-left y coordinate of the bounds.

width number

The width of the bounds, in pixels.

height number

The height of the bounds, in pixels.

centerOn boolean <optional> false

If true the Camera will automatically be centered on the new bounds.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setBounds
Since: 3.0.0
Focus
Focus
setDeadzone([width], [height])
Focus
Focus

Description:

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.

Parameters:

name type arguments description
width number <optional>

The width of the deadzone rectangle in pixels. If not specified the deadzone is removed.

height number <optional>

The height of the deadzone rectangle in pixels.

Returns:
Description:

This Camera instance.

Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 211)
Focus
Focus
setFlip(x, y)
Focus
Focus

Description:

Sets the horizontal and vertical flipped state of this Game Object.

A Game Object that is flipped will render inversed on the flipped axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

Parameters:

name type description
x boolean

The horizontal flipped state. false for no flip, or true to be flipped.

y boolean

The horizontal flipped state. false for no flip, or true to be flipped.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Flip#setFlip
Since: 3.0.0
Focus
Focus
setFlipX(value)
Focus
Focus

Description:

Sets the horizontal flipped state of this Game Object.

A Game Object that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

Parameters:

name type description
value boolean

The flipped state. false for no flip, or true to be flipped.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Flip#setFlipX
Since: 3.0.0
Focus
Focus
setFlipY(value)
Focus
Focus

Description:

Sets the vertical flipped state of this Game Object.

Parameters:

name type description
value boolean

The flipped state. false for no flip, or true to be flipped.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Flip#setFlipY
Since: 3.0.0
Focus
Focus
setFollowOffset([x], [y])
Focus
Focus

Description:

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.

Parameters:

name type arguments description
x number <optional>

The horizontal offset from the camera follow target.x position.

y number <optional>

The vertical offset from the camera follow target.y position.

Returns:
Description:

This Camera instance.

Since: 3.9.0
Source: src/cameras/2d/Camera.js (Line 637)
Focus
Focus
setLerp([x], [y])
Focus
Focus

Description:

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.

Parameters:

name type arguments Default description
x number <optional> 1

The amount added to the horizontal linear interpolation of the follow target.

y number <optional> 1

The amount added to the vertical linear interpolation of the follow target.

Returns:
Description:

This Camera instance.

Since: 3.9.0
Source: src/cameras/2d/Camera.js (Line 609)
Focus
Focus
setMask(mask, [fixedPosition])
Focus
Focus

Description:

Sets the mask to be applied to this Camera during rendering.

The mask must have been previously created and can be either a GeometryMask or a BitmapMask.

Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas.

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.

Parameters:

name type arguments Default description
mask Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask

The mask this Camera will use when rendering.

fixedPosition boolean <optional> true

Should the mask translate along with the Camera, or be fixed in place and not impacted by the Cameras transform?

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setMask
Since: 3.17.0
Focus
Focus
setName([value])
Focus
Focus

Description:

Sets the name of this Camera. This value is for your own use and isn't used internally.

Parameters:

name type arguments Default description
value string <optional> ''

The name of the Camera.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setName
Since: 3.0.0
Focus
Focus
setOrigin([x], [y])
Focus
Focus

Description:

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.

Parameters:

name type arguments Default description
x number <optional> 0.5

The horizontal origin value.

y number <optional> x

The vertical origin value. If not defined it will be set to the value of x.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setOrigin
Since: 3.11.0
Focus
Focus
Only webGL setPipeline(pipeline, [pipelineData], [copyData])
Focus
Focus

Description:

Sets the main WebGL Pipeline of this Game Object.

Also sets the pipelineData property, if the parameter is given.

Both the pipeline and post pipelines share the same pipeline data object.

Parameters:

name type arguments Default description
pipeline string | Phaser.Renderer.WebGL.WebGLPipeline

Either the string-based name of the pipeline, or a pipeline instance to set.

pipelineData object <optional>

Optional pipeline data object that is deep copied into the pipelineData property of this Game Object.

copyData boolean <optional> true

Should the pipeline data object be deep copied into the pipelineData property of this Game Object? If false it will be set by reference instead.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Pipeline#setPipeline
Since: 3.0.0
Focus
Focus
Only webGL setPipelineData(key, [value])
Focus
Focus

Description:

Adds an entry to the pipelineData object belonging to this Game Object.

If the 'key' already exists, its value is updated. If it doesn't exist, it is created.

If value is undefined, and key exists, key is removed from the data object.

Both the pipeline and post pipelines share the pipeline data object together.

Parameters:

name type arguments description
key string

The key of the pipeline data to set, update, or delete.

value any <optional>

The value to be set with the key. If undefined then key will be deleted from the object.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Pipeline#setPipelineData
Since: 3.50.0
Focus
Focus
setPosition(x, [y])
Focus
Focus

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.

Parameters:

name type arguments Default description
x number

The top-left x coordinate of the Camera viewport.

y number <optional> x

The top-left y coordinate of the Camera viewport.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setPosition
Since: 3.0.0
Focus
Focus
Only webGL setPostPipeline(pipelines, [pipelineData], [copyData])
Focus
Focus

Description:

Sets one, or more, Post Pipelines on this Game Object.

Post Pipelines are invoked after this Game Object has rendered to its target and are commonly used for post-fx.

The post pipelines are appended to the postPipelines array belonging to this Game Object. When the renderer processes this Game Object, it iterates through the post pipelines in the order in which they appear in the array. If you are stacking together multiple effects, be aware that the order is important.

If you call this method multiple times, the new pipelines will be appended to any existing post pipelines already set. Use the resetPostPipeline method to clear them first, if required.

You can optionally also sets the pipelineData property, if the parameter is given.

Both the pipeline and post pipelines share the pipeline data object together.

Parameters:

name type arguments Default description
pipelines string | Array.<string> | function | Array.<function()> | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline | Array.<Phaser.Renderer.WebGL.Pipelines.PostFXPipeline>

Either the string-based name of the pipeline, or a pipeline instance, or class, or an array of them.

pipelineData object <optional>

Optional pipeline data object that is deep copied into the pipelineData property of this Game Object.

copyData boolean <optional> true

Should the pipeline data object be deep copied into the pipelineData property of this Game Object? If false it will be set by reference instead.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Pipeline#setPostPipeline
Since: 3.50.0
Focus
Focus
setRotation([value])
Focus
Focus

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.

Parameters:

name type arguments description
value number <optional>

The rotation of the Camera, in radians.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setRotation
Since: 3.0.0
Focus
Focus
setRoundPixels(value)
Focus
Focus

Description:

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.

Parameters:

name type description
value boolean

true to round Camera pixels, false to not.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels
Since: 3.0.0
Focus
Focus
setScene(scene)
Focus
Focus

Description:

Sets the Scene the Camera is bound to.

Parameters:

name type description
scene Phaser.Scene

The Scene the camera is bound to.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setScene
Since: 3.0.0
Focus
Focus
setScroll(x, [y])
Focus
Focus

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.

Parameters:

name type arguments Default description
x number

The x coordinate of the Camera in the game world.

y number <optional> x

The y coordinate of the Camera in the game world.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setScroll
Since: 3.0.0
Focus
Focus
setSize(width, [height])
Focus
Focus

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.

Parameters:

name type arguments Default description
width number

The width of the Camera viewport.

height number <optional> width

The height of the Camera viewport.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setSize
Since: 3.0.0
Focus
Focus
Only webGL setTint([topLeft], [topRight], [bottomLeft], [bottomRight])
Focus
Focus

Description:

Sets an additive tint on this Game Object.

The tint works by taking the pixel color values from the Game Objects texture, and then multiplying it by the color value of the tint. You can provide either one color value, in which case the whole Game Object will be tinted in that color. Or you can provide a color per corner. The colors are blended together across the extent of the Game Object.

To modify the tint color once set, either call this method again with new values or use the tint property to set all colors at once. Or, use the properties tintTopLeft, tintTopRight, tintBottomLeftandtintBottomRight` to set the corner color values independently.

To remove a tint call clearTint.

To swap this from being an additive tint to a fill based tint set the property tintFill to true.

Parameters:

name type arguments Default description
topLeft number <optional> 0xffffff

The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object.

topRight number <optional>

The tint being applied to the top-right of the Game Object.

bottomLeft number <optional>

The tint being applied to the bottom-left of the Game Object.

bottomRight number <optional>

The tint being applied to the bottom-right of the Game Object.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Tint#setTint
Since: 3.0.0
Focus
Focus
Only webGL setTintFill([topLeft], [topRight], [bottomLeft], [bottomRight])
Focus
Focus

Description:

Sets a fill-based tint on this Game Object.

Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture with those in the tint. You can use this for effects such as making a player flash 'white' if hit by something. You can provide either one color value, in which case the whole Game Object will be rendered in that color. Or you can provide a color per corner. The colors are blended together across the extent of the Game Object.

To modify the tint color once set, either call this method again with new values or use the tint property to set all colors at once. Or, use the properties tintTopLeft, tintTopRight, tintBottomLeftandtintBottomRight` to set the corner color values independently.

To remove a tint call clearTint.

To swap this from being a fill-tint to an additive tint set the property tintFill to false.

Parameters:

name type arguments Default description
topLeft number <optional> 0xffffff

The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object.

topRight number <optional>

The tint being applied to the top-right of the Game Object.

bottomLeft number <optional>

The tint being applied to the bottom-left of the Game Object.

bottomRight number <optional>

The tint being applied to the bottom-right of the Game Object.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Tint#setTintFill
Since: 3.11.0
Focus
Focus
setViewport(x, y, width, [height])
Focus
Focus

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.

Parameters:

name type arguments Default description
x number

The top-left x coordinate of the Camera viewport.

y number

The top-left y coordinate of the Camera viewport.

width number

The width of the Camera viewport.

height number <optional> width

The height of the Camera viewport.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setViewport
Since: 3.0.0
Focus
Focus
setVisible(value)
Focus
Focus

Description:

Sets the visibility of this Camera.

An invisible Camera will skip rendering and input tests of everything it can see.

Parameters:

name type description
value boolean

The visible state of the Camera.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setVisible
Since: 3.10.0
Focus
Focus
setZoom([x], [y])
Focus
Focus

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.

As of Phaser 3.50 you can now set the horizontal and vertical zoom values independently.

Parameters:

name type arguments Default description
x number <optional> 1

The horizontal zoom value of the Camera. The minimum it can be is 0.001.

y number <optional> x

The vertical zoom value of the Camera. The minimum it can be is 0.001.

Returns:
Description:

This Camera instance.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#setZoom
Since: 3.0.0
Focus
Focus
shake([duration], [intensity], [force], [callback], [context])
Focus
Focus

Description:

Shakes the Camera by the given intensity over the duration specified.

Parameters:

name type arguments Default description
duration number <optional> 100

The duration of the effect in milliseconds.

intensity number | Phaser.Math.Vector2 <optional> 0.05

The intensity of the shake.

force boolean <optional> false

Force the shake effect to start immediately, even if already running.

callback function <optional>

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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 392)
Focus
Focus
shutdown()
Focus
Focus

Description:

Removes all listeners.

Inherited from: Phaser.Events.EventEmitter#shutdown
Since: 3.0.0
Focus
Focus
startFollow(target, [roundPixels], [lerpX], [lerpY], [offsetX], [offsetY])
Focus
Focus

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.

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.

Parameters:

name type arguments Default description
target object | Phaser.GameObjects.GameObject

The target for the Camera to follow.

roundPixels boolean <optional> false

Round the camera position to whole integers to avoid sub-pixel rendering?

lerpX number <optional> 1

A 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.

lerpY number <optional> 1

A 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.

offsetX number <optional> 0

The horizontal offset from the camera follow target.x position.

offsetY number <optional> 0

The vertical offset from the camera follow target.y position.

Returns:
Description:

This Camera instance.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 659)
Focus
Focus
stopFollow()
Focus
Focus

Description:

Stops a Camera from following a Game Object, if previously set via Camera.startFollow.

Returns:
Description:

This Camera instance.

Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 724)
Focus
Focus
toJSON()
Focus
Focus

Description:

Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties.

Returns:
Description:

A well-formed object suitable for conversion to JSON.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#toJSON
Since: 3.0.0
Focus
Focus
toggleFlipX()
Focus
Focus

Description:

Toggles the horizontal flipped state of this Game Object.

A Game Object that is flipped horizontally will render inversed on the horizontal axis. Flipping always takes place from the middle of the texture and does not impact the scale value. If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Flip#toggleFlipX
Since: 3.0.0
Focus
Focus
toggleFlipY()
Focus
Focus

Description:

Toggles the vertical flipped state of this Game Object.

Returns:
Description:

This Game Object instance.

Inherited from: Phaser.GameObjects.Components.Flip#toggleFlipY
Since: 3.0.0
Focus
Focus
<protected> update(time, delta)
Focus
Focus

Description:

Internal method called automatically by the Camera Manager.

Parameters:

name type description
time number

The current timestamp as generated by the Request Animation Frame or SetTimeout.

delta number

The delta time, in ms, elapsed since the last frame.

Overrides: Phaser.Cameras.Scene2D.BaseCamera#update
Since: 3.0.0
Source: src/cameras/2d/Camera.js (Line 759)
Focus
Focus
<private> updateSystem()
Focus
Focus

Description:

Internal method called automatically when the viewport changes.

Inherited from: Phaser.Cameras.Scene2D.BaseCamera#updateSystem
Since: 3.12.0
Focus
Focus
zoomTo(zoom, [duration], [ease], [force], [callback], [context])
Focus
Focus

Description:

This effect will zoom the Camera to the given scale, over the duration and with the ease specified.

Parameters:

name type arguments Default description
zoom number

The target Camera zoom value.

duration number <optional> 1000

The duration of the effect in milliseconds.

ease string | function <optional> 'Linear'

The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function.

force boolean <optional> false

Force the pan effect to start immediately, even if already running.

callback Phaser.Types.Cameras.Scene2D.CameraPanCallback <optional>

This 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.

context any <optional>

The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs.

Returns:
Description:

This Camera instance.

Since: 3.11.0
Source: src/cameras/2d/Camera.js (Line 464)
Focus
Focus