Text

 

Props

NameTypeDefaultDescription
active
boolean

Assigns the active property to the instance. Setting this to false will prevent onUpdate etc. props from running.

See: https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.GameObject.html#active__anchor

allowRotation
boolean

 

alpha
number Corners

 

angle
number

The angle of this Game Object as expressed in degrees.

Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left and -90 is up.

If you prefer to work in radians, see the rotation property instead.

blendMode
string BlendModes

Sets the Blend Mode being used by this Game Object.

This can be a const, such as Phaser.BlendModes.SCREEN, or an integer, such as 4 (for Overlay)

Under WebGL only the following Blend Modes are available:

  • ADD
  • MULTIPLY
  • SCREEN
  • ERASE

Canvas has more available depending on browser support.

You can also create your own custom Blend Modes in WebGL.

Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these reasons try to be careful about the construction of your Scene and the frequency of which blend modes are used.

crop
{ x?: number; y?: number; height?: number; width?: number; }

 

defaultPipeline
WebGLPipeline

The initial WebGL pipeline of this Game Object.

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

depth
number

The depth of this Game Object within the Scene.

The depth is also known as the ‘z-index’ in some environments, and allows you to change the rendering order of Game Objects, without actually moving their position in the display list.

The default depth is zero. A Game Object with a higher depth value will always render in front of one with a lower value.

Setting the depth will queue a depth sort event within the Scene.

displayHeight
number

The displayed height of this Game Object.

This value takes into account the scale factor.

Setting this value will adjust the Game Object’s scale property.

displayOrigin
XY

 

displayWidth
number

The displayed width of this Game Object.

This value takes into account the scale factor.

Setting this value will adjust the Game Object’s scale property.

flipX
boolean

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.

flipY
boolean

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.

height
number

The native (un-scaled) height of this Game Object.

Changing this value will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or use the displayHeight property.

interactive
boolean InputConfiguration

Enables input events on the GameObject. Phaser will use the texture to determine the hit area. If this GameObject does not have a texture then you will need to manually set the hit area by passing in an object

mask
BitmapMask GeometryMask

The Mask this Game Object is using during render.

name
string

Assigns a name to the instance. This can helpful when you need to find other instances by name.

See: https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.GameObject.html#name__anchor

onCreate
(self: Instance) => void

Called after object is created and added to the scene

onDrag
(self: Instance, pointer: Pointer, dragX: number, dragY: number) => void

 

onDragEnd
(self: Instance, pointer: Pointer, dragX: number, dragY: number) => void

 

onDragEnter
(self: Instance, pointer: Pointer, target: GameObject) => void

 

onDragLeave
(self: Instance, pointer: Pointer, target: GameObject) => void

 

onDragOver
(self: Instance, pointer: Pointer, target: GameObject) => void

 

onDragStart
(self: Instance, pointer: Pointer, dragX: number, dragY: number) => void

 

onDrop
(self: Instance, pointer: Pointer, target: GameObject) => void

 

onPointerDown
(self: Instance, pointer: Pointer, localX: number, localY: number, event: EventData) => void

 

onPointerMove
(self: Instance, pointer: Pointer, localX: number, localY: number, event: EventData) => void

 

onPointerOut
(self: Instance, pointer: Pointer, event: EventData) => void

 

onPointerOver
(self: Instance, pointer: Pointer, localX: number, localY: number, event: EventData) => void

 

onPointerUp
(self: Instance, pointer: Pointer, localX: number, localY: number, event: EventData) => void

 

onPointerWheel
(self: Instance, pointer: Pointer, deltaX: number, deltaY: number, deltaZ: number, event: EventData) => void

 

onPostUpdate
(self: Instance, time: number, delta: number) => void

Called during the scene’s postupdate loop

onPreUpdate
(self: Instance, time: number, delta: number) => void

Called during the scene’s preupdate loop

onUpdate
(self: Instance, time: number, delta: number) => void

Called during the scene’s update loop

origin
XY

 

pipeline
WebGLPipeline

The current WebGL pipeline of this Game Object.

ref
RefFunction Text

 

rotation
number

The angle of this Game Object in radians.

Phaser uses a right-hand clockwise rotation system, where 0 is right, PI/2 is down, +-PI is left and -PI/2 is up.

If you prefer to work in degrees, see the angle property instead.

scale
XY

 

scrollFactor
XY

 

style
TextStyle

 

text
string string[]

 

tint
Corners & { value?: number; fill?: boolean; }

 

visible
boolean

The visible state of the Game Object.

An invisible Game Object will skip rendering, but will still process update logic.

w
number

The w position of this Game Object.

width
number

The native (un-scaled) width of this Game Object.

Changing this value will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or use the displayWidth property.

x
number

The x position of this Game Object.

y
number

The y position of this Game Object.

z
number

The z position of this Game Object.

Note: The z position does not control the rendering order of 2D Game Objects. Use {@link Phaser.GameObjects.Components.Depth#depth} instead.