Component·phaser·v1.0.0·MIT
Platformer Player
A configurable Phaser platformer player controller with coyote time, jump buffering, variable jump height, and acceleration-based ground movement.
#player#platformer#physics#input
Install
npx gamecn add platformer-playerUsage
ts
import { PlatformerPlayer } from '@/components/PlatformerPlayer';
// In your scene's create():
const player = new PlatformerPlayer(this, 100, 100);
// In your scene's update():
player.update(time, delta);Source preview
Compatibility
| Engines | phaser >=3.80.0 <4.0.0 |
| Frameworks | vanilla, react |
| Languages | typescript |
| Bundlers | vite |
| Platforms | web, mobile-web |
Files installed
- {components}/PlatformerPlayer.ts
- {assets}/player/player.png(asset)
- docs/gamecn/platformer-player.md(docs)
Dependencies
npm
phaser@^3.80.0
Notes
Usage
import { PlatformerPlayer } from "@/components/PlatformerPlayer";
class GameScene extends Phaser.Scene {
preload(): void {
this.load.spritesheet("player", "assets/player/player.png", {
frameWidth: 32,
frameHeight: 32,
});
}
create(): void {
this.player = new PlatformerPlayer(this, 100, 100);
// Add platforms, colliders, etc. as usual
}
update(time: number, delta: number): void {
this.player.update(time, delta);
}
private player!: PlatformerPlayer;
}Options
| Option | Default | Description |
|---|---|---|
speed |
200 |
Maximum horizontal speed (px/s). |
acceleration |
1500 |
Horizontal acceleration (px/s²). Higher feels snappier. |
jumpVelocity |
-420 |
Initial jump impulse (px/s, negative = up). |
coyoteTimeMs |
100 |
Grace period after leaving ground where jumps still register. |
jumpBufferMs |
120 |
Window before landing where a queued jump triggers. |
variableJumpCutoff |
0.5 |
Multiplier applied to upward velocity when the jump button is released early. |
textureKey |
"player" |
Texture key — must match your preload spritesheet. |
keys |
{LEFT, RIGHT, SPACE} |
Override key bindings. |
Feel notes
- Coyote time lets players still jump for a few frames after walking off a ledge. Without it, edge-of-platform jumps feel unresponsive.
- Jump buffering queues a jump press if the player presses just before landing. Without it, players have to time presses perfectly.
- Variable jump height lets players control jump arc by holding the button longer. Tap = short hop, hold = full jump.
Compatibility
- Phaser ≥ 3.80
- TypeScript projects (Vite recommended)
- Works with both Arcade Physics and Matter (extend the class for Matter).
Related
- Input ManagerUtility
Engine-agnostic input action mapper. Map logical actions ('jump', 'left') to keyboard bindings and query state without coupling gameplay code to the DOM keyboard API.
- Mobile JoystickComponent
On-screen virtual joystick for touch input. Renders to a DOM element; exposes a 2D vector for gameplay. Engine-agnostic.
- Asteroid DodgerTemplate
Asteroid Dodger — a Phaser 3 starter mirrored from OpusGameLabs/game-creator.
- Barn DefenseTemplate
Barn Defense — a Phaser 3 starter mirrored from OpusGameLabs/game-creator.