Blocky
The Blocky Filter Controller.
This filter controller manages a blocky effect.
The blocky effect works by taking the central pixel of a block of pixels
and using it to fill the entire block, creating a pixelated effect.
It reduces the resolution of an image,
creating a pixelated or blocky appearance.
This is often used for stylistic purposes, such as pixel art.
One technique is to render the game at a higher resolution,
scaled up by a factor of N,
and then apply the blocky effect at size N.
This creates large, visible pixels, suitable for further stylization.
The effect can also be used to obscure certain elements within the game,
such as during a transition or to censor specific content.
Blocky works best on games with no anti-aliasing,
so it can read unfiltered pixel colors from the original image.
It preserves the colors of the original art, instead of blending them
like the Pixelate filter.
A Blocky effect is added to a Camera via the FilterList component:
const camera = this.cameras.main;
camera.filters.internal.addBlocky({ size: 4 });
camera.filters.external.addBlocky({ size: { x: 2, y: 4 } }, offset: { x: 1, y: 2 });
Constructor
new Blocky(camera, [config])
Parameters
| name | type | optional | description |
|---|---|---|---|
| camera | Phaser.Cameras.Scene2D.Camera | No | The Camera that owns this filter. |
| config | Phaser.Types.Filters.BlockyConfig | Yes | The configuration object for the Blocky effect. |
Scope: static
Extends
Source: src/filters/Blocky.js#L10
Since: 4.0.0
Inherited Members
From Phaser.Filters.Controller:
Public Members
offset
offset: Phaser.Types.Math.Vector2Like
Description:
The offset of the blocks from the top left corner of the image.
Source: src/filters/Blocky.js#L72
Since: 4.0.0
size
size: Phaser.Types.Math.Vector2Like
Description:
The size of the blocks.
You can set the x and y values to any numbers,
but the filter will limit them to a minimum of 1.
Source: src/filters/Blocky.js#L57
Since: 4.0.0
Inherited Methods
From Phaser.Filters.Controller: