npm phaser 4.0.0-beta.3
Phaser v4.0.0 Beta 3

2 days ago

Thanks to the community feedback in the Phaser Discord we decided to rework the way RenderFilters work:

Previously, the RenderFilters object wrapped game objects to apply Filters. This worked well in several ways, but because it replaced the existing game object, it made object references less reliable.

The decision was made to change Filters to a component on game objects. This is similar to the old FX system, but it is now built into the base GameObject, so it can be used everywhere. Filters are not FX (they're better).

For those who have been using Phaser 4 beta 1 or 2, this will change the way you use filters. The core principles are the same, however: filters are still divided into internal and external lists.

The new way to use filters is thus:

// Set up filter systems.
gameObject.enableFilters();

// Create filter controllers.
const blur = gameObject.filters.internal.addBlur();

When you run enableFilters(), Phaser creates an internal camera to handle the object's filters, and adds a RenderStep function.

By default, when there are no active filters to render, the RenderStep skips straight to renderWebGL. If you want the object to render to a framebuffer without rendering a filter, you can set gameObject.filtersForceComposite = true. This can be useful when you want to composite alpha, e.g. when you have several objects in a Container or Layer and you don't want to see them through each other, you can leave their alpha at 1, set filtersForceComposite, and reduce the alpha of gameObject.filterCamera.

Filters run focusFilters every time they render by default. This differs from RenderFilters.focus, which didn't run every time. This method ensures that the filterCamera is always locked onto the object. Some objects don't have enough properties to accurately lock on to, so the system will guess, and fall back to the screen resolution. You can run gameObject.focusFiltersOverride to manually set the camera target.

In general, this runs much like FX did - but with more control and better compatibility.

For more details about this release, please see the Dev Logs in Issue 211 of our Phaser World newsletter (due out on Friday 27th December)

Don't miss a new phaser release

NewReleases is sending notifications on new releases.