physics-arcade

Implements Arcade Physics in Phaser 4 including collisions, gravity, and physics bodies.

Updated May 7, 2021
One-click install
npx skills add https://github.com/travispwingo/travispwingo.github.io --skill physics-arcade-travispwingo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: physics-arcade
Source: https://github.com/travispwingo/travispwingo.github.io/tree/main/mario/docs/skills/physics-arcade
Command: npx skills add https://github.com/travispwingo/travispwingo.github.io --skill physics-arcade-travispwingo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up 2D physics in Phaser 4 games involves many moving parts: enabling the physics system in GameConfig, creating dynamic and static bodies, wiring collision detection, and tuning velocity, gravity, and bounce. This Skill provides the patterns and API reference needed to implement Arcade Physics correctly without digging through source code. ## Core Features & Use Cases - Physics Setup & Bodies: Enable Arcade Physics in GameConfig and create dynamic sprites, static platforms, physics groups, and standalone bodies via this.physics.add. - Collision Handling: Register persistent colliders and overlaps with callbacks, use one-shot collision checks, and filter collisions with category bitmasks. - Movement & World Control: Configure velocity, acceleration, drag, bounce, gravity, world bounds, and physics events like collide, overlap, and worldbounds. - Use Case: Build a platformer where the player sprite collides with static ground platforms, collects coins via overlap triggers, bounces off world bounds, and uses collision categories so enemy bullets only hit the player. ## Quick Start Ask the AI to create a Phaser 4 scene with Arcade Physics where a player sprite collides with static platforms and collects coins using overlap detection.

Frequently Asked Questions about physics-arcade

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

FAQPage Schema
How do I enable Arcade Physics in Phaser 4?▼

Enable Arcade Physics by adding a physics block to your GameConfig with default set to 'arcade' and optional arcade settings like gravity and debug. Then create physics objects in a scene using this.physics.add.sprite or this.physics.add.staticGroup.

What is the difference between collide and overlap in Phaser?▼

Collide performs separation, pushing bodies apart so they cannot pass through each other. Overlap only detects intersection without moving anything, making it the right choice for triggers like pickups and sensors.

How do I make a static platform in Phaser Arcade Physics?▼

Create static platforms with this.physics.add.staticImage, staticSprite, or staticGroup. After changing a static body's position or scale, call refreshBody or body.reset to sync the physics body, since static bodies do not auto-sync.

Why are my Phaser physics collision events not firing?▼

World events like collide, overlap, and worldbounds require opt-in per body. Set body.onCollide, body.onOverlap, or body.onWorldBounds to true before the corresponding world event will be emitted.

How do collision categories work in Phaser Arcade Physics?▼

Collision categories use bitmask values to filter which bodies collide. Call this.physics.nextCategory to get a category, assign it with setCollisionCategory, then define allowed targets with setCollidesWith. A maximum of 32 categories is supported.

When should I disable the RTree in Phaser Arcade Physics?▼

The RTree spatial index is enabled by default and speeds up lookups, but becomes expensive to rebuild with very large body counts. Set useTree to false in the arcade config when simulating 5000 or more dynamic bodies.