Skip to content

Commit 274ec1f

Browse files
Improve documentation around Container masks.
They are stackable in WebGL, but not Canvas.
1 parent 7cd83f3 commit 274ec1f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

skills/groups-and-containers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fgLayer.add(this.add.sprite(400, 300, 'player'));
4040
| **Physics** | Via physics.add.group() | Limited (offsets if not at 0,0) | No |
4141
| **Input** | No (children can) | Yes (needs hit area shape) | No |
4242
| **Object pooling** | Yes (getFirstDead, kill) | No | No |
43-
| **Masks** | No | Yes (not per-child) | Yes |
43+
| **Masks** | No | Yes (not per-child in Canvas) | Yes |
4444
| **Alpha/blend/visible** | No (batch via setVisible) | Yes | Yes |
4545
| **Nesting** | N/A | Container in Container | Cannot go in Container |
4646
| **Extends** | EventEmitter | GameObject | List |
@@ -324,7 +324,7 @@ Cannot be added to a Container. Containers can be added to Layers.
324324

325325
5. **Physics + Container is problematic.** If a Container is not at (0,0), physics bodies on children will be offset. Avoid physics bodies on Container children.
326326

327-
6. **Container children cannot be individually masked.** Only the Container itself can have a mask. Masks do not stack for nested Containers.
327+
6. **Container children cannot be individually masked in Canvas rendering.** Only the Container itself can have a mask. Masks do not stack for nested Containers. Masks do stack in WebGL rendering.
328328

329329
7. **Group.get() vs Group.getFirst() differ.** `get(x, y)` is shorthand for `getFirst(false, true, x, y)` -- finds first *inactive* member and creates if none found. `getFirst(state)` defaults to `active===false` without auto-creating.
330330

src/gameobjects/container/Container.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ var tempTransformMatrix = new Components.TransformMatrix();
4040
*
4141
* Containers can include other Containers for deeply nested transforms.
4242
*
43-
* Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked.
44-
* The masks do not 'stack up'. Only a Container on the root of the display list will use its mask.
43+
* Containers can have masks set on them and can be used as a mask too.
44+
* Because masks are filters, the container's children can also have masks,
45+
* and the Container's mask will be applied over the top.
46+
* In Canvas rendering, only the Container's mask will be applied.
4547
*
4648
* Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them
4749
* to use as their hit area. Container children can also be enabled for input, independent of the Container.

0 commit comments

Comments
 (0)