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
| Field | Script name | Kind | Default | What it does |
|---|---|---|---|---|
| Texture | texture | asset | none | The shape; only its alpha is read. |
| Size | size | two numbers (x, y) | (32, 32) | Size in local units before the node transform is applied. |
| Anchor | anchor | two 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. |
| Channel | channel | number, 0 to 7 | 0 | Which mask channel this writes. |
| Alpha Cutoff | alpha_cutoff | number, 0 to 1, step 0.01 | 0.5 | How opaque a pixel of the mask must be to count as inside. |
| Sort Layer | layer | number | 0 | Lower draws first. |
| Enabled | enabled | checkbox | on | Whether this mask is active right now. |