Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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.
.claude/skills/gamedev-skills-phaser-arcade-physics/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 74% | 0% |
| case-07 | ✓→✓ | = Same ✓ | 60% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 56% | 0% |
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.
world bounds, and collision/overlap resolution between sprites, groups, and tiles.
physics: { default: 'arcade' } and code callsthis.physics.add.*, body.setVelocity, or this.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.
{...}, debug: true } } in the game or scene config. Turn debug on while building to see body outlines and velocity vectors.
this.physics.add.sprite(...) (dynamic)or this.physics.add.staticImage(...) (static), or attach to an existing object with this.physics.add.existing(obj).
x/y. Use setVelocity,setAcceleration, gravity, setBounce, and setCollideWorldBounds. The engine integrates position from velocity each step (already frame-rate independent).
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.
this.physics.add.group() (dynamic) orstaticGroup() (platforms) so one collider call handles all members.
body.onFloor() / body.blocked.down beforejumping. Run with debug: true and confirm bodies, contacts, and bounds.
jsconst 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);
jscreate() { 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 }
jscreate() { 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); }
js// 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); });
jsthis.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); }
this.add.sprite instead ofthis.physics.add.sprite (or this.physics.add.existing(obj)), so it has no body.
sprite.x directly fights the engine → move dynamic bodies withsetVelocity/setAcceleration. Direct position writes can tunnel through colliders.
the velocity vector and rescale to the intended speed.
staticGroup, or setbody.setImmovable(true) on a dynamic platform.
onFloor() is always false → the body needs something to collide with; add thecollider against the ground/platforms before checking, and ensure gravity is on.
call body.updateFromGameObject() (or refreshBody() on the game object).
collider/overlap once in create,not in update.
setSize/setCircle/setOffset hitboxes, collision categories/masks, and worldbounds events), read references/bodies-and-collision.md.
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.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | fail→pass | 12,358 | 5,438 | -56% | 1 | 1 | 0% | 2,590 | 2,922 | +13% | 0 | 0 | — |
case-04 | pass→pass | 16,611 | 14,179 | -15% | 1 | 1 | 0% | 1,971 | 3,439 | +74% | 0 | 0 | — |
case-07 | pass→pass | 15,334 | 14,132 | -8% | 1 | 1 | 0% | 2,677 | 4,284 | +60% | 0 | 0 | — |
case-05 | fail→pass | 16,130 | 8,538 | -47% | 1 | 1 | 0% | 2,910 | 3,442 | +18% | 0 | 0 | — |
case-06 | pass→pass | 18,568 | 15,711 | -15% | 1 | 1 | 0% | 2,470 | 3,848 | +56% | 0 | 0 | — |
case-01 | fail→fail | 22,961 | 17,980 | -22% | 1 | 1 | 0% | 3,862 | 4,723 | +22% | 0 | 0 | — |
case-02 | pass→pass | 16,917 | 9,748 | -42% | 1 | 1 | 0% | 3,216 | 3,750 | +17% | 0 | 0 | — |
case-08 | pass→pass | 8,589 | 9,129 | +6% | 1 | 1 | 0% | 1,477 | 2,662 | +80% | 0 | 0 | — |
case-09 | pass→pass | 10,977 | 4,795 | -56% | 1 | 1 | 0% | 1,049 | 2,760 | +163% | 0 | 0 | — |
case-10 | pass→pass | 15,817 | 7,354 | -54% | 1 | 1 | 0% | 1,906 | 3,196 | +68% | 0 | 0 | — |
case-11 | pass→pass | 8,598 | 4,680 | -46% | 1 | 1 | 0% | 1,604 | 2,759 | +72% | 0 | 0 | — |
case-12 | pass→pass | 11,613 | 14,728 | +27% | 1 | 1 | 0% | 2,083 | 3,561 | +71% | 0 | 0 | — |
case-13 | pass→pass | 7,691 | 7,550 | -2% | 1 | 1 | 0% | 1,409 | 3,174 | +125% | 0 | 0 | — |
case-14 | pass→pass | 6,212 | 4,718 | -24% | 1 | 1 | 0% | 1,154 | 2,711 | +135% | 0 | 0 | — |
case-15 | pass→pass | 8,651 | 5,070 | -41% | 1 | 1 | 0% | 1,473 | 2,712 | +84% | 0 | 0 | — |
case-16 | pass→pass | 9,071 | 2,838 | -69% | 1 | 1 | 0% | 1,587 | 2,367 | +49% | 0 | 0 | — |
case-17 | pass→pass | 5,218 | 3,284 | -37% | 1 | 1 | 0% | 951 | 2,452 | +158% | 0 | 0 | — |
case-18 | pass→pass | 5,222 | 6,047 | +16% | 1 | 1 | 0% | 896 | 2,919 | +226% | 0 | 0 | — |
case-19 | pass→pass | 7,486 | 3,639 | -51% | 1 | 1 | 0% | 1,183 | 2,643 | +123% | 0 | 0 | — |
case-20 | pass→pass | 11,274 | 7,395 | -34% | 1 | 1 | 0% | 1,670 | 2,954 | +77% | 0 | 0 | — |
case-21 | pass→pass | 10,157 | 5,919 | -42% | 1 | 1 | 0% | 1,752 | 2,908 | +66% | 0 | 0 | — |
case-22 | pass→pass | 14,367 | 10,021 | -30% | 1 | 1 | 0% | 2,328 | 3,411 | +47% | 0 | 0 | — |
case-23 | pass→pass | 8,988 | 5,427 | -40% | 1 | 1 | 0% | 1,466 | 2,979 | +103% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.