Skip to main content
Version: Phaser v4.2.0

StencilReference

A StencilReference Game Object.

A StencilReference is a special type of Game Object that uses a Stencil as a reference for its own rendering. This allows you to re-render a Stencil using different settings.

For example, you can add a layer with a Stencil with some complex geometry, draw objects affected by the stencil layer, then use a StencilReference to subtract the same layer without recreating it.

It is WebGL-only.

A StencilReference temporarily changes the settings on the target Stencil, then restores them after rendering. Thus, it keeps the original Stencil's transforms. The stencil options can be changed by setting the properties on this object. Note that these properties will be set to default values, so if you have configured the targetStencil with its own properties, you should configure this with those properties as well, altered to your requirements.

See the Phaser.GameObjects.Stencil documentation for more details.

Constructor

new StencilReference(scene, targetStencil, [options])

Parameters

nametypeoptionaldescription
scenePhaser.SceneNoThe Scene to which this Game Object belongs.
targetStencilPhaser.GameObjects.StencilNoThe Stencil to use as a reference.
optionsPhaser.Types.GameObjects.Stencil.StencilOptionsYesThe options for the StencilReference.

Scope: static

Extends

Phaser.GameObjects.GameObject
Phaser.GameObjects.Components.StencilModifier
Phaser.GameObjects.Components.Visible

Source: src/gameobjects/stencilreference/StencilReference.js#L13
Since: 4.2.0

Inherited Members​

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.StencilModifier:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:


Public Members​

blendMode​

blendMode: number​

Description:

The blend mode to use when rendering the stencil reference. This is read-only, and is only used for internal compliance. Stencil drawing uses its own combination rules.

Source: src/gameobjects/stencilreference/StencilReference.js#L108
Since: 4.2.0


targetStencil​

targetStencil: Phaser.GameObjects.Stencil​

Description:

The Stencil to use as a reference.

Source: src/gameobjects/stencilreference/StencilReference.js#L62
Since: 4.2.0


Inherited Methods​

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.RenderSteps:

From Phaser.GameObjects.Components.StencilModifier:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:


Public Methods​

preDestroy​

<instance> preDestroy()​

Description:

Pre-destroy callback.

Source: src/gameobjects/stencilreference/StencilReference.js#L128
Since: 4.2.0