groups-and-containers

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser developers often struggle to choose between Groups, Containers, and Layers when organizing game objects, leading to broken transforms, failed pooling, or misplaced render order. This Skill provides decision guidance, API references, and working patterns for all three structures in Phaser 4. ## Core Features & Use Cases - Structure Selection Guidance: Compares Group, Container, and Layer across transforms, display list behavior, physics, input, and pooling so you pick the right one. - Object Pooling Patterns: Covers getFirstDead, killAndHide, maxSize, and pool capacity queries for reusable bullets, enemies, and particles. - Nested Transforms and Render Ordering: Shows Container hierarchies with inherited position, scale, and alpha, plus Layer-based depth control. - Use Case: When building a bullet system, use the pooling pattern with a physics Group; when building a HUD, use a Container with setScrollFactor(0) so children move as one unit. ## Quick Start Ask how to pool bullets with a Phaser Group or how to move a HUD's children together using a Container, and apply the provided code patterns in your Scene's create method.

Frequently Asked Questions about groups-and-containers

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

FAQPage Schema
How do I pool objects in Phaser with a Group?

Create a Group with a maxSize and classType, then call group.get(x, y) to reuse the first inactive member or create a new one. Deactivate objects with killAndHide instead of destroying them so they stay available for reuse.

What is the difference between Phaser Group and Container?

A Group is a logical collection with no position or transform, ideal for pooling and physics. A Container is on the display list with position, rotation, scale, and alpha that children inherit, suited for composite UI elements.

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

Use a Layer when you only need render-order control 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 does my Phaser Container not respond to input events?

Containers have no implicit size, so setInteractive fails without a hit area. Call container.setSize(width, height) before setInteractive() to define the clickable region.

Can I use physics bodies on children inside a Phaser Container?

Physics on Container children is problematic because bodies become offset when the Container is not at (0,0). Use a physics Group via this.physics.add.group() instead for collidable collections.

Why does moving a Phaser Group not move its children?

Groups are not on the display list and have no transform, so setting a Group's position does nothing visually. Use a Container if children must move, rotate, or scale together as a unit.