These docs are for an outdated version of Phaser The documentation on this page is for Phaser 2.4.4. The latest release is 2.9.2.

Constructor

Phaser. Filter

new Filter(game, uniforms, fragmentSrc)

This is a base Filter class to use for any Phaser filter development.

Parameters
Name Type Description
game Phaser.Game

A reference to the currently running game.

uniforms object

Uniform mappings object

fragmentSrc Array | string

The fragment shader code. Either an array, one element per line of code, or a string.

Source code: core/Filter.js (Line 16)

Public Properties

dirty : boolean

Internal PIXI var.

Default Value
  • true
Source code: core/Filter.js (Line 47)

fragmentSrc :array | string

The fragment shader code.

Type
  • array | string
Source code: core/Filter.js (Line 95)

game : Phaser.Game

A reference to the currently running game.

Source code: core/Filter.js (Line 21)

height : number

The height (resolution uniform)

Source code: core/Filter.js (Line 230)

padding : number

Internal PIXI var.

Source code: core/Filter.js (Line 53)

prevPoint : Phaser.Point

The previous position of the pointer (we don't update the uniform if the same)

Source code: core/Filter.js (Line 58)

type : number

The const type of this object, either Phaser.WEBGL_FILTER or Phaser.CANVAS_FILTER.

Source code: core/Filter.js (Line 27)

uniforms : Object

Default uniform mappings. Compatible with ShaderToy and GLSLSandbox.

Source code: core/Filter.js (Line 69)

width : number

The width (resolution uniform)

Source code: core/Filter.js (Line 214)

Public Methods

addToWorld(x, y, width, height, anchorX, anchorY) → {Phaser.Image}

Creates a new Phaser.Image object using a blank texture and assigns this Filter to it. The image is then added to the world.

If you don't provide width and height values then Filter.width and Filter.height are used.

If you do provide width and height values then this filter will be resized to match those values.

Parameters
Name Type Argument Default Description
x number <optional>
0

The x coordinate to place the Image at.

y number <optional>
0

The y coordinate to place the Image at.

width number <optional>

The width of the Image. If not specified (or null) it will use Filter.width. If specified Filter.width will be set to this value.

height number <optional>

The height of the Image. If not specified (or null) it will use Filter.height. If specified Filter.height will be set to this value.

anchorX number <optional>
0

Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right.

anchorY number <optional>
0

Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right.

Returns

The newly added Image object.

Source code: core/Filter.js (Line 146)

destroy()

Clear down this Filter and null out references

Source code: core/Filter.js (Line 200)

init()

Should be over-ridden.

Source code: core/Filter.js (Line 101)

setResolution(width, height)

Set the resolution uniforms on the filter.

Parameters
Name Type Description
width number

The width of the display.

height number

The height of the display.

Source code: core/Filter.js (Line 109)

update(pointer)

Updates the filter.

Parameters
Name Type Argument Description
pointer Phaser.Pointer <optional>

A Pointer object to use for the filter. The coordinates are mapped to the mouse uniform.

Source code: core/Filter.js (Line 122)