groups-and-containers

Organizes Phaser 4 game objects using Groups, Containers, and Layers with pooling and transforms.

Updated Jun 10, 2026
One-click install
npx skills add https://github.com/mudman1986/quarterless --skill groups-and-containers-mudman1986
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: groups-and-containers
Source: https://github.com/mudman1986/quarterless/tree/main/.github/skills/groups-and-containers
Command: npx skills add https://github.com/mudman1986/quarterless --skill groups-and-containers-mudman1986

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser 4 developers often struggle to choose between Groups, Containers, and Layers when organizing game objects, leading to broken transforms, misplaced physics bodies, or inefficient object churn. This Skill provides decision tables, code patterns, and gotchas for picking and using the right structure. ## Core Features & Use Cases - Group vs Container vs Layer guidance: A comparison table covering transforms, display list behavior, exclusivity, and pooling so you pick the correct structure. - Object pooling patterns: Ready-to-use getFirstDead, killAndHide, and maxSize pool recipes for bullets, enemies, and particles. - Nested transform and render-order recipes: Container hierarchies for HUDs and composite UI, plus Layer-based depth bucketing. - Use Case: Building a shooter where bullets must be pooled, the HUD must scale as one unit, and background/entity/UI render in fixed order — this Skill supplies all three patterns with correct API calls. ## Quick Start Ask the AI to show how to create a pooled bullet group and a nested HUD container in a Phaser 4 scene.

Frequently Asked Questions about groups-and-containers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an object pool in Phaser 4?

Create a Group with a maxSize and classType, then use group.get(x, y) or getFirstDead(true) to reuse inactive members. Deactivate objects with killAndHide() instead of destroying them so they stay available for reuse.

What is the difference between Group and Container in Phaser?

A Group is a logical collection with no position or transform, ideal for pooling and physics. A Container is a display-list object whose position, rotation, scale, and alpha are inherited by its children, suited for composite UI.

When should I use a Layer instead of a Container in Phaser?

Use a Layer when you only need render-order bucketing and shared alpha, blend mode, or mask without position or scale. Layers are lighter than Containers because they skip per-child transform matrix math.

Why are physics bodies offset when children are inside a Container?

Physics bodies on Container children become offset when the Container is not positioned at (0,0), because body coordinates do not follow the Container transform. The recommended fix is to avoid physics bodies on Container children.

Does killAndHide remove an object from a Phaser Group?

No, killAndHide only sets active=false and visible=false on the member. The object remains in the Group so it can be reactivated later through get() or getFirstDead(), which is the basis of pooling.

How do I make a Phaser Container receive input events?

Containers have no implicit size, so you must call container.setSize(width, height) before setInteractive() will work with a hit area. Without setSize, pointer events on the Container will not fire.