phaser - v4.0.0-rc.4
    Preparing search index...

    Provides methods used for getting and setting the mask of a Game Object.

    This only works under the Canvas Renderer. For WebGL, see Phaser.GameObjects.Components.FilterList#addMask.

    interface Mask {
        mask: GeometryMask;
        clearMask(destroyMask?: boolean): this;
        createGeometryMask<G extends GameObjects.Graphics, S extends Shape>(
            graphics?: GameObjects.Graphics | Shape,
        ): GeometryMask;
        setMask(mask: GeometryMask): this;
    }

    Implemented by

    Index

    Properties

    The Mask this Game Object is using during render.

    Methods

    • Clears the mask that this Game Object was using.

      This only works in the Canvas Renderer. In WebGL, use a Mask filter instead (see Phaser.GameObjects.Components.FilterList#addMask).

      Parameters

      • OptionaldestroyMask: boolean

        Destroy the mask before clearing it? Default false.

      Returns this

    • Sets the mask that this Game Object will use to render with.

      The mask must have been previously created and must be a GeometryMask. This only works in the Canvas Renderer. In WebGL, use a Mask filter instead (see Phaser.GameObjects.Components.FilterList#addMask).

      If a mask is already set on this Game Object it will be immediately replaced.

      Masks are positioned in global space and are not relative to the Game Object to which they are applied. The reason for this is that multiple Game Objects can all share the same mask.

      Masks have no impact on physics or input detection. They are purely a rendering component that allows you to limit what is visible during the render pass.

      Parameters

      • mask: GeometryMask

        The mask this Game Object will use when rendering.

      Returns this