Skills

Melonjs Physics

Use this skill for collision, physics bodies, movement, and spatial queries in melonJS...

Install

npx skills add melonjs/melonJS --skill melonjs-physics -g -a claude-code -y
Repository
melonjs/melonJS6.4k
Category
Engineering
Updated
3d ago
License
MIT
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

Use this skill for collision, physics bodies, movement, and spatial queries in melonJS, the built-in SAT world and the planck/matter adapters. Covers bodyDef vs Body, collision types and masks, the collision callback family and their firing rules, raycast/queryAABB/querySphere, the behaviour differences between adapters, and which one to pick for a given game. Triggers on: which physics engine, choosing an adapter, rotation collision, rotating body, torque, joints, stacking, Body, bodyDef, collision, collisionType, collisionMask, onCollision, onCollisionStart, onCollisionActive, raycast, queryAABB, querySphere, PlanckAdapter, MatterAdapter, gravity, velocity, applyForce, isGrounded, SAT.

Physics and collision

melonJS has a built-in SAT collision world and two optional rigid-body adapters. Movement, collision callbacks and spatial queries all behave differently depending on which is active, and several of the differences fail silently.

Choosing a world

when
built-in (default)Arcade-style: platformers, top-down games. Fast, position-based, not Newtonian.
@melonjs/planck-adapterFull rigid-body dynamics, stacking, joints, realistic restitution.
@melonjs/matter-adapterSame class of thing, backed by matter-js.

Picking one

Start with the built-in. It is the default for a reason: no dependency, the smallest bundle, and its position-based model is what most 2D games actually want, a platformer's jump arc is a designed curve, not a simulated one, and tuning gravity against a solver you are fighting is a bad afternoon.

Move to an adapter when the game needs something the builtin cannot express, and these are the usual triggers:

Read the whole SKILL.md on GitHub

More in Engineering