new BitmapMask(scene, renderable)
Parameters:
Name | Type | Description |
---|---|---|
scene |
Phaser.Scene | The Scene which this Bitmap Mask will be used in. |
renderable |
Phaser.GameObjects.GameObject | A renderable Game Object that uses a texture, such as a Sprite. |
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 11)
Members
-
bitmapMask :Phaser.GameObjects.GameObject
-
A renderable Game Object that uses a texture, such as a Sprite.
Type:
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 66)
-
dirty :boolean
-
Whether the Bitmap Mask is dirty and needs to be updated.
Type:
- boolean
- Since: 3.0.0
- Default Value:
-
- true
- Source: src/display/mask/BitmapMask.js (Line 95)
-
invertAlpha :boolean
-
Whether to invert the masks alpha.
If
true
, the alpha of the masking pixel will be inverted before it's multiplied with the masked pixel. Essentially, this means that a masked area will be visible only if the corresponding area in the mask is invisible.Type:
- boolean
- Since: 3.1.2
- Source: src/display/mask/BitmapMask.js (Line 123)
-
<readonly> isStencil :boolean
-
Is this mask a stencil mask?
Type:
- boolean
- Since: 3.17.0
- Source: src/display/mask/BitmapMask.js (Line 135)
-
mainFramebuffer :WebGLFramebuffer
-
The framebuffer to which a masked Game Object is rendered.
Type:
- WebGLFramebuffer
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 105)
-
mainTexture :WebGLTexture
-
The texture used for the main framebuffer.
Type:
- WebGLTexture
- Since: 3.0.0
- Default Value:
-
- null
- Source: src/display/mask/BitmapMask.js (Line 85)
-
maskFramebuffer :WebGLFramebuffer
-
The framebuffer to which the Bitmap Mask's masking Game Object is rendered.
Type:
- WebGLFramebuffer
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 114)
-
maskTexture :WebGLTexture
-
The texture used for the masks framebuffer.
Type:
- WebGLTexture
- Since: 3.0.0
- Default Value:
-
- null
- Source: src/display/mask/BitmapMask.js (Line 75)
-
renderer :Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer
-
A reference to either the Canvas or WebGL Renderer that this Mask is using.
Type:
- Since: 3.11.0
- Source: src/display/mask/BitmapMask.js (Line 57)
Methods
-
clearMask()
-
Deletes the
mainTexture
andmaskTexture
WebGL Textures and deletes themainFramebuffer
andmaskFramebuffer
too, nulling all references.This is called when this mask is destroyed, or if you try to creat a new mask from this object when one is already set.
- Since: 3.50.0
- Source: src/display/mask/BitmapMask.js (Line 186)
-
createMask()
-
Creates the WebGL Texture2D objects and Framebuffers required for this mask. If this mask has already been created, then
clearMask
is called first.- Since: 3.50.0
- Source: src/display/mask/BitmapMask.js (Line 152)
-
destroy()
-
Destroys this BitmapMask 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/BitmapMask.js (Line 289)
-
postRenderCanvas(renderer)
-
This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer The Canvas Renderer which would be rendered to.
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 276)
-
postRenderWebGL(renderer)
-
Finalizes rendering of a masked Game Object.
This resets the previously bound framebuffer and switches the WebGL Renderer to the Bitmap Mask Pipeline, which uses a special fragment shader to apply the masking effect.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer The WebGL Renderer to clean up.
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 246)
-
preRenderCanvas(renderer, mask, camera)
-
This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer The Canvas Renderer which would be rendered to.
mask
Phaser.GameObjects.GameObject The masked Game Object which would be rendered.
camera
Phaser.Cameras.Scene2D.Camera The Camera to render to.
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 261)
-
preRenderWebGL(renderer, maskedObject, camera)
-
Prepares the WebGL Renderer to render a Game Object with this mask applied.
This renders the masking Game Object to the mask framebuffer and switches to the main framebuffer so that the masked Game Object will be rendered to it instead of being rendered directly to the frame.
Parameters:
Name Type Description renderer
Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer The WebGL Renderer to prepare.
maskedObject
Phaser.GameObjects.GameObject The masked Game Object which will be drawn.
camera
Phaser.Cameras.Scene2D.Camera The Camera to render to.
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 229)
-
setBitmap(renderable)
-
Sets a new masking Game Object for the Bitmap Mask.
Parameters:
Name Type Description renderable
Phaser.GameObjects.GameObject A renderable Game Object that uses a texture, such as a Sprite.
- Since: 3.0.0
- Source: src/display/mask/BitmapMask.js (Line 216)