phaser-arcade-physics
gamedev-skills/awesome-gamedev-agent-skills
Add movement and collision to Phaser games with the lightweight Arcade Physics engine.
What is phaser-arcade-physics?
Phaser 4 Arcade Physics enables sprite movement, velocity, gravity, and collision detection using AABB rectangles and circles. Use it when building platformers, top-down games, or any Phaser scene that needs physics-driven motion and collision resolution between sprites, groups, and world bounds.
- Enable Arcade Physics in game or scene config with gravity and debug visualization
- Attach physics bodies to sprites and control movement via velocity, acceleration, and gravity
- Resolve collisions with colliders (separation) and overlaps (detection-only) between sprites and groups
- Check ground contact and implement jumping with onFloor() and blocked.down
- Pool and reuse dynamic objects like bullets with physics groups
- Set world bounds, bouncing, and immovable platforms for level geometry
How to install phaser-arcade-physics
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill phaser-arcade-physics- Phaser 4.2 installed and a game instance with a scene
- Basic understanding of Phaser scenes and sprite creation (see phaser-core skill)
How to use phaser-arcade-physics
- 1.Enable Arcade Physics in your game config by setting physics: { default: 'arcade', arcade: { gravity: {...}, debug: true } }
- 2.Create physics-enabled sprites with this.physics.add.sprite() or attach bodies to existing objects with this.physics.add.existing()
- 3.Drive movement using body.setVelocity(), setAcceleration(), and gravity instead of directly setting x/y coordinates
- 4.Add colliders with this.physics.add.collider() to separate bodies and overlaps with this.physics.add.overlap() for detection-only interactions
- 5.Check ground contact with body.onFloor() or body.blocked.down before allowing jumps in platformers
- 6.Use physics groups (this.physics.add.group()) to handle collisions with many objects at once
Use cases
- Build a platformer with gravity-driven jumping and ground detection
- Create a top-down shooter with velocity-based player movement and bullet physics
- Implement collectible pickups using overlap detection without pushing the player
- Design a level with static platforms that collide with the player but don't move
- Handle enemy knockback and collision reactions with collider callbacks
- Game developers building 2D games in Phaser 4
- Platformer and top-down game designers
- Developers new to physics engines who need a lightweight, AABB-based solution
phaser-arcade-physics FAQ
Use Arcade Physics for simple 2D games with rectangular and circular bodies; it's lightweight and fast. Use Matter Physics for complex rigid-body simulations with polygons, hinges, and stacking. The two engines do not interact.
The sprite was likely created with this.add.sprite() instead of this.physics.add.sprite(). Physics bodies only exist on sprites created through the physics system or added with this.physics.add.existing().
After setting independent X and Y velocities, normalize the velocity vector and rescale it: body.velocity.normalize().scale(speed).
The body needs an active collider against the ground or platforms to detect contact. Ensure you've called this.physics.add.collider() before checking onFloor(), and that gravity is enabled.
Add them once in create(). Adding them every frame in update() wastes performance and can cause unexpected behavior.
Full instructions (SKILL.md)
Source of truth, from gamedev-skills/awesome-gamedev-agent-skills.
name: phaser-arcade-physics description: > Use Phaser 4 Arcade Physics: enable the world, give sprites bodies, set velocity/acceleration/gravity, and resolve collisions with colliders, overlaps, groups, and world bounds. Use when a Phaser game needs movement or collisions — when the user mentions Arcade Physics, this.physics, setVelocity, collider, overlap, gravity, onFloor, or a platformer/top-down controller. For game config, scenes, and the loader use phaser-core.
Phaser 4 Arcade Physics
Add movement and collision to a Phaser game with the lightweight Arcade Physics engine (AABB rectangles and circles only). Targets Phaser 4.2 for new projects; inspect the installed major before editing an existing project.
When to use
- Use for top-down or platformer movement, velocity/acceleration/gravity, bouncing, world bounds, and collision/overlap resolution between sprites, groups, and tiles.
- Use when the scene enables
physics: { default: 'arcade' }and code callsthis.physics.add.*,body.setVelocity, orthis.physics.add.collider.
When not to use: the Game config, scene structure, asset loading, or
cameras → use phaser-core. Hinges, springs, complex polygons, or stacking
rigid bodies → use Matter physics (a different engine; Arcade and Matter bodies
do not interact). For engine-agnostic feel tuning see physics-tuning.
Core workflow
- Enable the world. Set
physics: { default: 'arcade', arcade: { gravity: {...}, debug: true } }in the game or scene config. Turndebugon while building to see body outlines and velocity vectors. - Give a sprite a body. Create it with
this.physics.add.sprite(...)(dynamic) orthis.physics.add.staticImage(...)(static), or attach to an existing object withthis.physics.add.existing(obj). - Drive it through the body, not by setting
x/y. UsesetVelocity,setAcceleration, gravity,setBounce, andsetCollideWorldBounds. The engine integrates position from velocity each step (already frame-rate independent). - Resolve interactions.
this.physics.add.collider(a, b)separates bodies;this.physics.add.overlap(a, b, cb)detects without separating (pickups, triggers). Pass a callback to react. - Group many objects. Use
this.physics.add.group()(dynamic) orstaticGroup()(platforms) so one collider call handles all members. - Check ground contact with
body.onFloor()/body.blocked.downbefore jumping. Run withdebug: trueand confirm bodies, contacts, and bounds.
Patterns
1. Enable Arcade Physics (game config)
const config = {
type: Phaser.AUTO,
width: 800, height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: { x: 0, y: 600 }, // top-down? use { x: 0, y: 0 }
debug: false // true to draw bodies + velocity while building
}
},
scene: [PlayScene]
};
new Phaser.Game(config);
2. Top-down movement (velocity from input)
create() {
this.player = this.physics.add.sprite(400, 300, 'player');
this.player.setCollideWorldBounds(true);
this.cursors = this.input.keyboard.createCursorKeys();
}
update() {
const speed = 220;
const body = this.player.body;
body.setVelocity(0); // reset each frame
if (this.cursors.left.isDown) body.setVelocityX(-speed);
if (this.cursors.right.isDown) body.setVelocityX(speed);
if (this.cursors.up.isDown) body.setVelocityY(-speed);
if (this.cursors.down.isDown) body.setVelocityY(speed);
body.velocity.normalize().scale(speed); // keep diagonals same speed
}
3. Platformer jump (gravity + ground check)
create() {
this.player = this.physics.add.sprite(100, 450, 'player');
this.player.setCollideWorldBounds(true);
// Static platforms: one body each, never moved by collisions.
this.platforms = this.physics.add.staticGroup();
this.platforms.create(400, 568, 'ground');
this.physics.add.collider(this.player, this.platforms);
this.cursors = this.input.keyboard.createCursorKeys();
}
update() {
const onGround = this.player.body.blocked.down; // or this.player.body.onFloor()
if (this.cursors.left.isDown) this.player.setVelocityX(-160);
else if (this.cursors.right.isDown) this.player.setVelocityX(160);
else this.player.setVelocityX(0);
if (this.cursors.up.isDown && onGround) this.player.setVelocityY(-450);
}
4. Colliders vs overlaps (separate vs detect)
// Push apart and react: player vs enemies.
this.physics.add.collider(this.player, this.enemies, (player, enemy) => {
this.handleHit(player, enemy);
});
// Detect without pushing: collect coins. The 4th arg is an optional
// process callback returning a boolean to filter pairs before the main callback.
this.physics.add.overlap(this.player, this.coins, (player, coin) => {
coin.disableBody(true, true); // deactivate + hide
this.registry.inc('score', 10);
});
5. A group of moving objects
this.bullets = this.physics.add.group({
defaultKey: 'bullet',
maxSize: 30 // pool size; reuse instead of allocating
});
fire(x, y) {
const bullet = this.bullets.get(x, y); // reuses a dead bullet if available
if (!bullet) return;
bullet.enableBody(true, x, y, true, true);
bullet.setVelocityY(-500);
}
Pitfalls
- Sprite ignores physics → it was added with
this.add.spriteinstead ofthis.physics.add.sprite(orthis.physics.add.existing(obj)), so it has no body. - Setting
sprite.xdirectly fights the engine → move dynamic bodies withsetVelocity/setAcceleration. Direct position writes can tunnel through colliders. - Diagonal movement is faster → independent X and Y velocities add up; normalise the velocity vector and rescale to the intended speed.
- Platforms get pushed by the player → use a
staticGroup, or setbody.setImmovable(true)on a dynamic platform. onFloor()is always false → the body needs something to collide with; add thecollideragainst the ground/platforms before checking, and ensure gravity is on.- Moved a static body but collisions are stale → static bodies don't auto-sync;
call
body.updateFromGameObject()(orrefreshBody()on the game object). - Collider added every frame → register
collider/overlaponce increate, not inupdate.
References
- For body anatomy and tuning (drag, bounce, max velocity, custom
setSize/setCircle/setOffsethitboxes, collision categories/masks, andworldboundsevents), readreferences/bodies-and-collision.md.
Related skills
phaser-core— game config, scenes, loader, cameras (the prerequisite setup).physics-tuning— engine-agnostic feel (fixed timestep, tunneling, jitter).platformer/tower-defense— genres that compose this skill.level-design— laying out tile/platform geometry these bodies collide with.
Related skills
More from gamedev-skills/awesome-gamedev-agent-skills and the wider catalog.

phaser-core
Set up and debug Phaser 4 games: Game config, Scene lifecycle, asset loading, cameras, and cross-scene communication.

physics-tuning
Tune game physics for stable, responsive motion—fixed timestep, interpolation, CCD, mass/drag, and collision layers.

pixijs-rendering
Set up PixiJS v8 rendering: async Application, asset loading, scene graph, ticker loop, and pointer events.

platformer
Build 2D platformers with tight jump feel: coyote time, jump buffering, variable height, and level structure.

procedural-gen
Generate reproducible game content—terrain, dungeons, and loot—from seeded algorithms and noise.

prototype-fast
Build a playable mechanic prototype in ~1 hour to answer 'is it fun?' with greybox primitives and a hard timebox.