groups-and-containers

Organize Phaser 4 game objects with Groups, Containers, and Layers.

Updated Apr 16, 2026
One-click install
npx skills add https://github.com/GiantCroissant-Lunar/proto-breakout --skill groups-and-containers-giantcroissant-lunar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: groups-and-containers
Source: https://github.com/GiantCroissant-Lunar/proto-breakout/tree/main/.agent/skills/01-phaser/groups-and-containers
Command: npx skills add https://github.com/GiantCroissant-Lunar/proto-breakout --skill groups-and-containers-giantcroissant-lunar

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Organize and manage Phaser 4 game objects efficiently using Groups for logical collections, Containers for visual transforms, and Layers for render-order control.

Core Features & Use Cases

  • Object pooling and grouping: reuse objects with Groups to minimize allocations and manage lifecycles.
  • Container-based transforms: apply a single transform to all children, enabling nested UI and composite objects.
  • Layered rendering: control render order by grouping visuals into Layers and adjusting depths.
  • Nested structures: compose complex UIs and gameobject hierarchies with containers within containers.
  • APIs and utilities: add, remove, query, and iterate over children with batch operations (getFirstDead, getFirstAlive).

Quick Start

Create a Group to pool enemies, a Container for a HUD element that follows the camera, and place them in distinct Layers to manage render order.

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 game objects in Phaser 4 to reduce memory allocations?

Use Phaser 4 Groups to implement object pooling, reusing inactive objects instead of creating new ones. Methods like getFirstDead and getFirstAlive query available objects, minimizing allocations and managing lifecycles efficiently during gameplay.

What is the difference between Groups, Containers, and Layers in Phaser 4?

Groups manage logical collections for object pooling, Containers apply visual transforms to child objects, and Layers control render order via depth adjustment. Use Groups for lifecycle management, Containers for nested UI transforms, and Layers for visual sorting.

How do I apply a single visual transform to multiple game objects in Phaser 4?

Apply a single visual transform to multiple game objects using Containers in Phaser 4. Containers enable nested UI structures and composite objects by treating children as a group, so transforms like position and scale affect all contained items simultaneously.

Can I nest Containers within other Containers for complex UI in Phaser 4?

Yes, Containers support nesting to compose complex UIs and gameobject hierarchies in Phaser 4. You can place containers within containers to build composite objects, allowing layered visual transforms across parent and child structures.

How do I control render order for grouped game objects in Phaser 4?

Control render order in Phaser 4 by grouping visuals into Layers and adjusting their depths. Layers isolate render-order control from logical grouping, letting you sort visual elements independently of their container or group hierarchy.

What Phaser 4 APIs are available for adding, removing, and querying game objects?

Phaser 4 provides batch APIs to add, remove, query, and iterate over children within Groups and Containers. Utilities like getFirstDead and getFirstAlive help retrieve specific objects based on their active state for pooling and lifecycle management.