new GeometryMask(scene, graphicsGeometry)
Parameters:
Name | Type | Description |
---|---|---|
scene |
Phaser.Scene | This parameter is not used. |
graphicsGeometry |
Phaser.GameObjects.Graphics | The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. |
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 9)
Members
-
geometryMask :Phaser.GameObjects.Graphics
-
The Graphics object which describes the Geometry Mask.
Type:
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 41)
-
invertAlpha :boolean
-
Similar to the BitmapMasks invertAlpha setting this to true will then hide all pixels drawn to the Geometry Mask.
This is a WebGL only feature.
Type:
- boolean
- Since: 3.16.0
- Source: src/display/mask/GeometryMask.js (Line 50)
-
<readonly> isStencil :boolean
-
Is this mask a stencil mask?
Type:
- boolean
- Since: 3.17.0
- Source: src/display/mask/GeometryMask.js (Line 62)
Methods
-
applyStencil(renderer, camera, inc)
-
Applies the current stencil mask to the renderer.
Parameters:
Name Type Description renderer
Phaser.Renderer.WebGL.WebGLRenderer The WebGL Renderer instance to draw to.
camera
Phaser.Cameras.Scene2D.Camera The camera the Game Object is being rendered through.
inc
boolean Is this an INCR stencil or a DECR stencil?
- Since: 3.17.0
- Source: src/display/mask/GeometryMask.js (Line 160)
-
destroy()
-
Destroys this GeometryMask and nulls any references it holds.
Note that if a Game Object is currently using this mask it will not automatically detect you have destroyed it, so be sure to call
clearMask
on any Game Object using it, before destroying it.- Since: 3.7.0
- Source: src/display/mask/GeometryMask.js (Line 298)
-
postRenderCanvas(renderer)
-
Restore the canvas context's previous clipping path, thus turning off the mask for it.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer The Canvas Renderer instance being restored.
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 285)
-
postRenderWebGL(renderer)
-
Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it.
Parameters:
Name Type Description renderer
Phaser.Renderer.WebGL.WebGLRenderer The WebGL Renderer instance to draw flush.
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 218)
-
preRenderCanvas(renderer, mask, camera)
-
Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer The Canvas Renderer instance to set the clipping path on.
mask
Phaser.GameObjects.GameObject The Game Object being rendered.
camera
Phaser.Cameras.Scene2D.Camera The camera the Game Object is being rendered through.
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 264)
-
preRenderWebGL(renderer, child, camera)
-
Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask.
Parameters:
Name Type Description renderer
Phaser.Renderer.WebGL.WebGLRenderer The WebGL Renderer instance to draw to.
child
Phaser.GameObjects.GameObject The Game Object being rendered.
camera
Phaser.Cameras.Scene2D.Camera The camera the Game Object is being rendered through.
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 123)
-
setInvertAlpha( [value])
-
Sets the
invertAlpha
property of this Geometry Mask.Inverting the alpha essentially flips the way the mask works.
This is a WebGL only feature.
Parameters:
Name Type Argument Default Description value
boolean <optional>
true Invert the alpha of this mask?
- Since: 3.17.0
- Source: src/display/mask/GeometryMask.js (Line 100)
Returns:
This Geometry Mask
-
setShape(graphicsGeometry)
-
Sets a new Graphics object for the Geometry Mask.
Parameters:
Name Type Description graphicsGeometry
Phaser.GameObjects.Graphics The Graphics object which will be used for the Geometry Mask.
- Since: 3.0.0
- Source: src/display/mask/GeometryMask.js (Line 83)
Returns:
This Geometry Mask