Skip to content

Components

SpriteMask

A shape whose alpha decides where sprites on the same channel are allowed to draw, and never draws itself. A torch's reveal, a keyhole, a spotlight cutout.

On this page

Add it

+ Add node → Sprite Mask creates a node with it already on. Already have a node for it? Add component → SpriteMaskComponent.

From a script

A script on the same node writes these fields by name. SpriteMaskComponent is the name to pass.

rgs
set_point("SpriteMaskComponent", "size", vec2(32.0, 32.0));
set_point("SpriteMaskComponent", "anchor", vec2(0.5, 0.5));
set_number("SpriteMaskComponent", "alpha_cutoff", 0.5);
set_flag("SpriteMaskComponent", "enabled", true);

Fields

FieldScript nameKindDefaultWhat it does
TexturetextureassetnoneThe shape; only its alpha is read.
Sizesizetwo numbers (x, y)(32, 32)Size in local units before the node transform is applied.
Anchoranchortwo numbers (x, y), 0 to 1, step 0.01(0.5, 0.5)Anchor point on the mask: 0, 0 is the top-left corner, 0.5, 0.5 is the centre.
Channelchannelnumber, 0 to 70Which mask channel this writes.
Alpha Cutoffalpha_cutoffnumber, 0 to 1, step 0.010.5How opaque a pixel of the mask must be to count as inside.
Sort Layerlayernumber0Lower draws first.
EnabledenabledcheckboxonWhether this mask is active right now.