Skip to main content
Version: Phaser v4.0.0

Controller

The base class for a post-processing filter effect applied to a Camera.

Filters are visual effects rendered on top of a Camera's output, such as blur, glow, or color grading. Each filter is managed by a Controller, which holds its configuration and provides padding information to the renderer.

You should not normally create an instance of this class directly, but instead use one of the built-in filters that extend it, such as those found in the Phaser.Filters namespace.

You should not use a Controller for more than one Camera. Create a new instance for each Camera that you wish to apply the filter to. If you share Controllers, and destroy one owner, the Controller will be destroyed.

Constructor

new Controller(camera, renderNode)

Parameters

nametypeoptionaldescription
cameraPhaser.Cameras.Scene2D.CameraNoThe Camera that owns this filter.
renderNodestringNoThe ID of the RenderNode that this filter uses.

Scope: static

Source: src/filters/Controller.js#L10
Since: 4.0.0

Public Members

active

active: boolean

Description:

Toggle this boolean to enable or disable this filter, without removing it from and re-adding it to the Camera's filter list.

Source: src/filters/Controller.js#L34
Since: 4.0.0


allowBaseDraw

allowBaseDraw: boolean

Description:

If true, this filter will be permitted to draw to the base texture. This can be unwanted if, for example, the filter doesn't actually draw anything.

This is an internal flag used by the renderer. You should not modify this value directly.

Source: src/filters/Controller.js#L85
Since: 4.0.0


camera

camera: Phaser.Cameras.Scene2D.Camera

Description:

A reference to the Camera that owns this filter.

Source: src/filters/Controller.js#L44
Since: 4.0.0


currentPadding

currentPadding: Phaser.Geom.Rectangle

Description:

The padding currently being used by this filter. This is read during rendering via getPadding, and may be updated by subclass implementations. It is necessary for filters being used in an external list. You should not modify this value directly.

Source: src/filters/Controller.js#L73
Since: 4.0.0


ignoreDestroy

ignoreDestroy: boolean

Description:

Whether this filter controller will be destroyed when the FilterList that owns it is destroyed. If you enable this, you must ensure that you clean up the filter controller at an appropriate time. This allows you to reuse a controller for multiple objects; this is not recommended unless you know what you're doing. It tends to work best with external filters.

Source: src/filters/Controller.js#L101
Since: 4.0.0


paddingOverride

paddingOverride: Phaser.Geom.Rectangle

Description:

Padding override. This is on by default. If this is set, the filter will use this padding instead of calculating it. Prefer using setPaddingOverride instead of modifying this directly.

Source: src/filters/Controller.js#L62
Since: 4.0.0


renderNode

renderNode: string

Description:

The ID of the RenderNode that this filter uses.

Source: src/filters/Controller.js#L53
Since: 4.0.0


Public Methods

destroy

<instance> destroy()

Description:

Destroys this Controller and nulls any references it holds.

Source: src/filters/Controller.js#L183
Since: 4.0.0


getPadding

<instance> getPadding()

Description:

Returns the padding required for this filter. Most filters don't need extra padding, but some may sample beyond the texture boundaries, such as a blur or glow effect.

The bounds are encoded as a Rectangle. To enlarge the bounds, the top and left values should be negative, and the bottom and right values should be positive.

Returns: Phaser.Geom.Rectangle - The padding required by this filter.

Source: src/filters/Controller.js#L117
Since: 4.0.0


setActive

<instance> setActive(value)

Description:

Sets the active state of this filter.

A disabled filter will not be used.

Parameters:

nametypeoptionaldescription
valuebooleanNotrue to enable this filter, or false to disable it.

Returns: Phaser.Filters.Controller - This filter instance.

Source: src/filters/Controller.js#L166
Since: 4.0.0


setPaddingOverride

<instance> setPaddingOverride([left], [top], [right], [bottom])

Description:

Sets the padding override. If this is set, the filter will use this padding instead of calculating it. Call setPaddingOverride(null) to clear the override. Call setPaddingOverride() to set the padding to 0.

Parameters:

nametypeoptionaldefaultdescription
leftnumber | nullYes0The left padding.
topnumberYes0The top padding.
rightnumberYes0The right padding.
bottomnumberYes0The bottom padding.

Source: src/filters/Controller.js#L135
Since: 4.0.0