Skip to main content
Version: Phaser v4.0.0-rc.6

Phaser.GameObjects.Components.Filters

Scope: static

Source: src/gameobjects/components/Filters.js#L11
Since: 4.0.0

Static functions

filterCamera

filterCamera: Phaser.Cameras.Scene2D.Camera

Description:

The Camera used for filters.

You can use this to alter the perspective of filters.

It is not necessary to use this camera for ordinary rendering.

This is only available if you use the enableFilters method.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L58
Since: 4.0.0


filters

filters: Phaser.Types.GameObjects.FiltersInternalExternal, null

Description:

Get the filters lists.

This is an object with internal and external properties.

Each list is a {@see Phaser.GameObjects.Components.FilterList} object.

This is only available if you use the enableFilters method.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L73
Since: 4.0.0


filtersAutoFocus

filtersAutoFocus: boolean

Description:

Whether filterCamera should update every frame

to focus on the Game Object.

Disable this if you want to manually control the camera.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L125
Since: 4.0.0


filtersFocusContext

filtersFocusContext: boolean

Description:

Whether the filters should focus on the context,

rather than attempt to focus on the Game Object.

This is enabled automatically when enabling filters on objects

which don't have well-defined bounds.

This effectively sets the internal filters to render the same way

as the external filters.

This is only used if filtersAutoFocus is enabled.

The "context" is the framebuffer to which the Game Object is rendered.

This is usually the main framebuffer, but might be another framebuffer.

It can even be several different framebuffers if the Game Object is

rendered multiple times.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L138
Since: 4.0.0


filtersForceComposite

filtersForceComposite: boolean

Description:

Whether the Filters component should always draw to a framebuffer,

even if there are no active filters.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L162
Since: 4.0.0


maxFilterSize

maxFilterSize: Phaser.Math.Vector2

Description:

The maximum size of the base filter texture.

Filters may use a larger texture after the base texture is rendered.

The maximum texture size is at least 4096 in WebGL, based on the hardware.

You may set this lower to save memory or prevent resizing.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L112
Since: 4.0.0


renderFilters

renderFilters: boolean

Description:

Whether any filters should be rendered on this Game Object.

This is true by default, even if there are no filters yet.

Disable this to skip filter rendering.

Use willRenderFilters() to see if there are any active filters.

Tags:

  • webglOnly

Source: src/gameobjects/components/Filters.js#L97
Since: 4.0.0


Static functions

enableFilters

<instance> enableFilters()

Description:

Enable this Game Object to have filters.

You need to call this method if you want to use the filterCamera

and filters properties. It sets up the necessary data structures.

You may disable filter rendering with the renderFilters property.

This is a WebGL only feature. It will return early if not available.

Tags:

  • webglOnly

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L223
Since: 4.0.0


focusFilters

<instance> focusFilters()

Description:

Focus the filter camera.

This sets the size and position of the filter camera to match the GameObject.

This is called automatically on render if filtersAutoFocus is enabled.

This will focus on the GameObject's raw dimensions if available.

If the GameObject has no dimensions, this will focus on the context:

the camera belonging to the DrawingContext used to render the GameObject.

Context focus occurs during rendering,

as the context is not known until then.

Tags:

  • webglOnly

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L442
Since: 4.0.0


focusFiltersOnCamera

<instance> focusFiltersOnCamera(camera)

Description:

Focus the filter camera on a specific camera.

This is used internally when filtersFocusContext is enabled.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
cameraPhaser.Cameras.Scene2D.CameraNoThe camera to focus on.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L511
Since: 4.0.0


focusFiltersOverride

<instance> focusFiltersOverride([x], [y], [width], [height])

Description:

Manually override the focus of the filter camera.

This allows you to set the size and position of the filter camera manually.

It deactivates filtersAutoFocus when called.

The camera will set scroll to place the game object at the

given position within a rectangle of the given width and height.

For example, calling focusFiltersOverride(400, 200, 800, 600)

will focus the camera to place the object's center

100 pixels above the center of the camera (which is at 400x300).

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
xnumberYesThe x-coordinate of the focus point, relative to the filter size. Default is the center.
ynumberYesThe y-coordinate of the focus point, relative to the filter size. Default is the center.
widthnumberYesThe width of the focus area. Default is the filter width.
heightnumberYesThe height of the focus area. Default is the filter height.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L541
Since: 4.0.0


renderWebGLFilters

<instance> renderWebGLFilters(renderer, gameObject, drawingContext, [parentMatrix], [renderStep])

Description:

Render this object using filters.

This function's scope is not guaranteed, so it doesn't refer to this.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldefaultdescription
rendererPhaser.Renderer.WebGL.WebGLRendererNoThe WebGL Renderer instance to render with.
gameObjectPhaser.GameObjects.GameObjectNoThe Game Object being rendered.
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
parentMatrixPhaser.GameObjects.Components.TransformMatrixYesThe parent matrix of the Game Object, if it has one.
renderStepnumberYes0The index of this function in the Game Object's list of render processes. Used to support multiple rendering functions.

Returns: Phaser.Types.GameObjects.RenderWebGLStep - undefined

Source: src/gameobjects/components/Filters.js#L289
Since: 4.0.0


setFiltersAutoFocus

<instance> setFiltersAutoFocus(value)

Description:

Set whether filters should be updated every frame.

Sets the filtersAutoFocus property.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
valuebooleanNoWhether filters should be updated every frame.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L638
Since: 4.0.0


setFiltersFocusContext

<instance> setFiltersFocusContext(value)

Description:

Set whether the filters should focus on the context.

Sets the filtersFocusContext property.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
valuebooleanNoWhether the filters should focus on the context.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L655
Since: 4.0.0


setFiltersForceComposite

<instance> setFiltersForceComposite(value)

Description:

Set whether the filters should always draw to a framebuffer.

Sets the filtersForceComposite property.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
valuebooleanNoWhether the object should always draw to a framebuffer, even if there are no active filters.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L672
Since: 4.0.0


setFilterSize

<instance> setFilterSize(width, height)

Description:

Set the base size of the filter camera.

This is the size of the texture that internal filters will be drawn to.

External filters are drawn to the size of the context (usually the game canvas).

This is typically the size of the GameObject.

It is set automatically when the Game Object is rendered

and filtersAutoFocus is enabled.

Turn off auto focus to set it manually.

Technically, larger framebuffers may be used to provide padding.

This is the size of the final framebuffer used for "internal" rendering.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
widthnumberNoBase width of the filter texture.
heightnumberNoBase height of the filter texture.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L602
Since: 4.0.0


setRenderFilters

<instance> setRenderFilters(value)

Description:

Set whether the filters should be rendered.

Sets the renderFilters property.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
valuebooleanNoWhether the filters should be rendered.

Returns: Phaser.GameObjects.Components.Filters - undefined

Source: src/gameobjects/components/Filters.js#L689
Since: 4.0.0


willRenderFilters

<instance> willRenderFilters()

Description:

Whether this Game Object will render filters.

This is true if it has active filters,

and if the renderFilters property is also true.

Tags:

  • webglOnly

Returns: boolean - Whether the Game Object will render filters.

Source: src/gameobjects/components/Filters.js#L202
Since: 4.0.0