Phaser API Documentation

  Version: 
Filter

The Circle FX Controller.

This FX controller manages the circle effect for a Game Object.

This effect will draw a circle around the texture of the Game Object, effectively masking off any area outside of the circle without the need for an actual mask. You can control the thickness of the circle, the color of the circle and the color of the background, should the texture be transparent. You can also control the feathering applied to the circle, allowing for a harsh or soft edge.

Please note that adding this effect to a Game Object will not change the input area or physics body of the Game Object, should it have one.

A Circle effect is added to a Game Object via the FX component:

const sprite = this.add.sprite();

sprite.preFX.addCircle();
sprite.postFX.addCircle();

Constructor:

new Circle(gameObject, [thickness], [color], [backgroundColor], [scale], [feather])

Parameters:

name type arguments Default description
gameObject Phaser.GameObjects.GameObject

A reference to the Game Object that has this fx.

thickness number <optional> 8

The width of the circle around the texture, in pixels.

color number <optional> 0xfeedb6

The color of the circular ring, given as a number value.

backgroundColor number <optional> 0xff0000

The color of the background, behind the texture, given as a number value.

scale number <optional> 1

The scale of the circle. The default scale is 1, which is a circle the full size of the underlying texture.

feather number <optional> 0.005

The amount of feathering to apply to the circle from the ring.

Since: 3.60.0
Source: src/fx/Circle.js (Line 11)

Extends


Members

active: boolean
Focus
Focus

Description:

Toggle this boolean to enable or disable this effect, without removing and adding it from the Game Object.

Only works for Pre FX.

Post FX are always active.

Type:
boolean
Inherited from: Phaser.FX.Controller#active
Since: 3.60.0
Source: src/fx/Controller.js (Line 47)
Focus
Focus
backgroundAlpha: number
Focus
Focus

Description:

The alpha of the background, behind the texture, given as a number value.

Type:
number
Since: 3.70.0
Source: src/fx/Circle.js (Line 180)
Focus
Focus
backgroundColor: number
Focus
Focus

Description:

The color of the background, behind the texture, given as a number value.

Type:
number
Since: 3.60.0
Source: src/fx/Circle.js (Line 153)
Focus
Focus
color: number
Focus
Focus

Description:

The color of the circular ring, given as a number value.

Type:
number
Since: 3.60.0
Source: src/fx/Circle.js (Line 126)
Focus
Focus
feather: number
Focus
Focus

Description:

The amount of feathering to apply to the circle from the ring, extending into the middle of the circle. The default is 0.005, which is a very low amount of feathering just making sure the ring has a smooth edge. Increase this amount to a value such as 0.5 or 0.025 for larger amounts of feathering.

Type:
number
Since: 3.60.0
Source: src/fx/Circle.js (Line 73)
Focus
Focus

Description:

A reference to the Game Object that owns this effect.

Type:
Inherited from: Phaser.FX.Controller#gameObject
Since: 3.60.0
Source: src/fx/Controller.js (Line 38)
Focus
Focus
glcolor: Array.<number>
Focus
Focus

Description:

The internal gl color array for the ring color.

Type:
Array.<number>
Since: 3.60.0
Source: src/fx/Circle.js (Line 97)
Focus
Focus
glcolor2: Array.<number>
Focus
Focus

Description:

The internal gl color array for the background color.

Type:
Array.<number>
Since: 3.60.0
Source: src/fx/Circle.js (Line 106)
Focus
Focus
scale: number
Focus
Focus

Description:

The scale of the circle. The default scale is 1, which is a circle the full size of the underlying texture. Reduce this value to create a smaller circle, or increase it to create a circle that extends off the edges of the texture.

Type:
number
Since: 3.60.0
Source: src/fx/Circle.js (Line 61)
Focus
Focus
thickness: number
Focus
Focus

Description:

The width of the circle around the texture, in pixels. This value doesn't factor in the feather, which can extend the thickness internally depending on its value.

Type:
number
Since: 3.60.0
Source: src/fx/Circle.js (Line 86)
Focus
Focus
type: number
Focus
Focus

Description:

The FX_CONST type of this effect.

Type:
number
Inherited from: Phaser.FX.Controller#type
Since: 3.60.0
Source: src/fx/Controller.js (Line 29)
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Destroys this FX Controller.

Inherited from: Phaser.FX.Controller#destroy
Since: 3.60.0
Source: src/fx/Controller.js (Line 81)
Focus
Focus
setActive(value)
Focus
Focus

Description:

Sets the active state of this FX Controller.

A disabled FX Controller will not be updated.

Parameters:

name type description
value boolean

true to enable this FX Controller, or false to disable it.

Returns:
Description:

This FX Controller instance.

Inherited from: Phaser.FX.Controller#setActive
Since: 3.60.0
Source: src/fx/Controller.js (Line 62)
Focus
Focus