groups-and-containers

Select Phaser 4 Groups, Containers, and Layers for object pooling and transform inheritance.

1|Updated May 3, 2026
One-click install
npx skills add https://github.com/WanderTheWeeb/papas_trauma --skill groups-and-containers-wandertheweeb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: groups-and-containers
Source: https://github.com/WanderTheWeeb/papas_trauma/tree/main/skills/groups-and-containers
Command: npx skills add https://github.com/WanderTheWeeb/papas_trauma --skill groups-and-containers-wandertheweeb

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Phaser developers often struggle to choose between Group, Container, and Layer, and then run into performance and behavior issues when batching, pooling, or composing visual hierarchies.

Core Features & Use Cases

  • Pick the right display/logic primitive: Use Groups for logical collections and pooling, Containers for transform inheritance (position/rotation/scale/alpha) in composite UI, and Layers for render-order and batch-style visibility/effects.
  • Object pooling patterns: Use Group pooling methods like getFirstDead, get, kill, and killAndHide to reuse objects instead of constantly creating/destroying them.
  • Nested transforms & render ordering: Build HUDs with nested Containers, and control overall rendering behavior with Layers while avoiding unsupported nesting directions.

Use case: You need a reusable set of bullets or enemies that can be efficiently spawned/despawned and also want a camera-pinned HUD cluster that moves/rotates as one unit; this skill guides how to implement both correctly with the right Phaser objects.

Quick Start

Use the groups-and-containers skill to design your Phaser Scene using a Group for reusable pooled entities and a Container for a transform-inheriting HUD, applying a Layer only when you need render-order bucketing.

Frequently Asked Questions about groups-and-containers

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

FAQPage Schema
When should I use Phaser Groups versus Containers and Layers for structuring game objects?

Use Phaser Groups for logical collections and object pooling, Containers for composite UI hierarchies requiring transform inheritance like position and alpha, and Layers for render-order batching with shared blend effects. Choosing the correct primitive prevents performance and behavior issues.

How do I implement object pooling in Phaser 4 to efficiently reuse game entities?

Implement object pooling in Phaser 4 by using Group methods like getFirstDead and get to fetch inactive objects, then killAndHide to despawn them. This pattern reuses entities instead of constantly creating and destroying them, improving performance.

Can I build a camera-pinned HUD that moves and rotates as one unit in Phaser?

Yes, you can build a camera-pinned HUD cluster in Phaser by nesting Containers. Containers support transform inheritance for position, rotation, scale, and alpha, allowing your composite UI to move and rotate predictably as a single unit.

Does the rendering order of Phaser Layers support nested transforms?

Phaser Layers control render-order batching and apply shared visual effects like alpha and masks, but they do not handle nested transforms. You must avoid unsupported nesting directions to maintain predictable rendering behavior.

Why does my Phaser game lag when constantly spawning and despawning bullets?

Your Phaser game lags because constantly creating and destroying objects causes performance overhead. Use Groups with object pooling patterns like getFirstDead and killAndHide to reuse bullets and efficiently manage the object lifecycle without garbage collection spikes.