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
| name | type | optional | description |
|---|---|---|---|
| scene | Phaser.Scene | No | The Scene to which this Game Object belongs. |
| targetStencil | Phaser.GameObjects.Stencil | No | The Stencil to use as a reference. |
| options | Phaser.Types.GameObjects.Stencil.StencilOptions | Yes | The 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:
- filterCamera
- filters
- filtersAutoFocus
- filtersFocusContext
- filtersForceComposite
- maxFilterSize
- renderFilters
From Phaser.GameObjects.Components.StencilModifier:
- isStencilModifier
- stencilAlphaStrategy
- stencilClearValue
- stencilCompositeCheck
- stencilInvert
- stencilLayerMode
- stencilValueWrap
From Phaser.GameObjects.Components.Visible:
From Phaser.GameObjects.GameObject:
- active
- body
- cameraFilter
- data
- displayList
- ignoreDestroy
- input
- isDestroyed
- name
- parentContainer
- renderFlags
- scene
- state
- tabIndex
- type
- vertexRoundMode
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:
- addListener
- emit
- eventNames
- listenerCount
- listeners
- off
- on
- once
- removeAllListeners
- removeListener
- shutdown
From Phaser.GameObjects.Components.Filters:
- enableFilters
- focusFilters
- focusFiltersOnCamera
- focusFiltersOverride
- renderWebGLFilters
- setFiltersAutoFocus
- setFiltersFocusContext
- setFiltersForceComposite
- setFilterSize
- setRenderFilters
- willRenderFilters
From Phaser.GameObjects.Components.RenderSteps:
From Phaser.GameObjects.Components.StencilModifier:
- setStencilAlphaStrategy
- setStencilClearValue
- setStencilCompositeCheck
- setStencilInvert
- setStencilLayerMode
- setStencilValueWrap
From Phaser.GameObjects.Components.Visible:
From Phaser.GameObjects.GameObject:
- addedToScene
- addToDisplayList
- addToUpdateList
- destroy
- disableInteractive
- getData
- getDisplayList
- getIndexList
- incData
- removedFromScene
- removeFromDisplayList
- removeFromUpdateList
- removeInteractive
- setActive
- setData
- setDataEnabled
- setInteractive
- setName
- setState
- setVertexRoundMode
- toggleData
- toJSON
- update
- willRender
- willRoundVertices
Public Methods
preDestroy
<instance> preDestroy()
Description:
Pre-destroy callback.
Source: src/gameobjects/stencilreference/StencilReference.js#L128
Since: 4.2.0