phaser-core
Was er macht
Dieser Skill erklärt, wie du ein Phaser-Spiel im Browser einrichtest, von der Spielkonfiguration bis zu jedem Bildschirm. Er ist für Entwickler gedacht, die ein Phaser-Projekt beginnen oder reparieren.
Wann du ihn nutzt
- ✓Wenn du ein neues Phaser-Spiel beginnst oder seine Konfiguration einrichtest.
- ✓Wenn du Bildschirme als Szenen organisieren und Assets laden musst, bevor sie erscheinen.
- ✓Wenn Szenenübergänge oder Daten, die zwischen Szenen geteilt werden, in Phaser nicht funktionieren.
Link zum Skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/web-engines/phaser-core/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Richte ein Phaser-Spiel mit einem Titelbildschirm und einem Spielbildschirm ein, zwischen denen ich wechseln kann.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Skill erklärt die Spielkonfiguration, die Reihenfolge der Szenenfunktionen von init bis update, das Laden von Assets in preload und das Teilen von Zuständen zwischen Szenen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Phaser 4 Core
Set up the foundation of a Phaser game: the Game config, the Scene
lifecycle, asset loading, cameras, and passing data between scenes. Targets
Phaser 4.2 for new projects; keep an existing Phaser 3.90 project on its
pinned major unless the user explicitly asks for a migration.
When to use
- Use when starting a Phaser game, wiring the
Phaser.Gameconfig, structuringScenes, loading assets inpreload, or fixing scene transitions and shared state. - Use when the project has
phaserinpackage.jsonorimport Phaser from 'phaser', and code usespreload()/create()/update().
When not to use: movement, velocity, colliders, gravity, or overlap → use
phaser-arcade-physics. Complex rigid-body simulation uses Matter physics (a
separate concern). For cross-engine save/load patterns use save-systems.
Core workflow
- Detect the installed major first. Read
package.jsonand the lockfile. Use Phaser 4.2 for new work; do not silently rewrite a Phaser 3 project as Phaser 4. - Create the game from a config.
new Phaser.Game(config)withtype: Phaser.AUTO(WebGL with Canvas fallback), awidth/height, and ascenearray. The first scene (and any withactive: true) starts automatically. - Model each screen as a
Scene. SubclassPhaser.Scene, pass a uniquekeytosuper, and implement the lifecycle:init(data)→preload()→create(data)→update(time, delta). - Load assets in
preload, use them increate. Queued assets are not available untilcreate. The loader is per-scene; the cache it fills is global. - Reset per-run state in
init(), not the constructor. A scene instance is reused across restarts, so constructor-set fields keep stale values. - Move between screens with
this.scene.start/launch/switch/sleep/wake. Share data throughthis.registry(global) or a sibling scene's event emitter. - Run and observe. Serve the page, open it, and confirm assets load (watch the Network tab and console) and scenes switch as expected before assuming success.
Patterns
1. Game config + boot (ES module)
// main.js — one Game owns the renderer, loop, cache, and Scene Manager.
import Phaser from 'phaser';
import BootScene from './scenes/BootScene.js';
import PlayScene from './scenes/PlayScene.js';
const config = {
type: Phaser.AUTO, // WebGL if available, else Canvas
width: 800,
height: 600,
backgroundColor: '#1d1d28',
scale: { mode: Phaser.Scale.FIT, autoCenter: Phaser.Scale.CENTER_BOTH },
scene: [BootScene, PlayScene] // BootScene starts first
};
new Phaser.Game(config);
2. A Scene with the full lifecycle
// scenes/PlayScene.js
import Phaser from 'phaser';
export default class PlayScene extends Phaser.Scene {
constructor() {
super('play'); // unique scene key
}
init(data) {
// Reset run-specific state HERE so restarts start clean.
this.score = 0;
this.level = data.level ?? 1;
}
preload() {
// Queue downloads. Not usable until create().
this.load.image('player', 'assets/player.png');
this.load.spritesheet('coin', 'assets/coin.png', { frameWidth: 16, frameHeight: 16 });
}
create() {
this.player = this.add.sprite(400, 300, 'player');
this.scoreText = this.add.text(10, 10, 'Score: 0', { fontSize: '20px', color: '#fff' });
this.cursors = this.input.keyboard.createCursorKeys();
}
update(time, delta) {
// delta is milliseconds since last frame; divide by 1000 for seconds.
const speed = 200 * (delta / 1000);
if (this.cursors.left.isDown) this.player.x -= speed;
if (this.cursors.right.isDown) this.player.x += speed;
}
}
3. Cross-scene data + events
// The registry is a global DataManager shared by every scene.
this.registry.set('coins', 0); // in any scene
const coins = this.registry.get('coins'); // read anywhere
// React to registry changes (e.g. a HUD scene listening to gameplay):
this.registry.events.on('changedata-coins', (parent, value) => {
this.coinText.setText(`Coins: ${value}`);
});
// Talk directly to another running scene via its event emitter:
const ui = this.scene.get('hud');
ui.events.emit('show-message', 'Level cleared!');
4. Scene transitions (pick the right verb)
this.scene.start('gameover', { score: this.score }); // stop this scene, start target
this.scene.launch('hud');
Häufige Fragen
Was ist eine Phaser-Szene?
Eine Szene ist ein Bildschirm oder Zustand des Spiels, etwa ein Menü oder ein Level.
Welche Phaser-Version deckt das ab?
Es zielt für neue Projekte auf Phaser 4.2 und lässt bestehende Phaser-3-Projekte bei ihrer aktuellen Version.
Deckt das Bewegung und Kollisionen ab?
Nein. Dafür ist der Arcade-Physics-Skill zuständig.
Details
Originalbeschreibung des Autors
Set up and debug a Phaser 4 game: the Game config, the Scene lifecycle (init/preload/create/update), the asset loader, cameras, and cross-scene communication. Use when building or debugging a Phaser game — when the user mentions Phaser, Phaser.Game, Phaser.Scene, preload/create/update, this.load, this.add, or scene transitions. For Arcade Physics movement/collisions use phaser-arcade-physics.
Beliebtheit
- GitHub-Sterne
- 6.6k
- Platz im Ranking
- #13859
- Lizenz
- Apache-2.0
- Aktualisiert
- 28.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
router
6.6kHilft deinem Agenten, für eine Anfrage den passenden Spiele-Entwicklungs-Skill zu finden, indem er deine Engine und die Art der Aufgabe erkennt.
ai-behavior-trees-utility-ai
6.6kHilft deinem Agenten, einen Behavior Tree und eine Utility-KI für Gegner und Figuren zu bauen, die Aktionen nach Priorität und Punktwert wählen.
audio-design
6.6kBringt deinem Agenten das Mischen von Spiel-Audio bei: Busse, Lautstärke in Dezibel, Absenkung unter Dialogen, adaptive Musik und Variationen von Soundeffekten.
camera-systems
6.6kHilft deinem Agenten, Spielkameras zu bauen, die sanft folgen, innerhalb des Levels bleiben und sich in 3D um die Figur drehen oder umschauen lassen.
Ähnliche Skills
angular-developer
280kHilft deinem Agenten bei Angular-Code und gibt Tipps zur Projektstruktur. Nützlich für neue Projekte, einzelne Code-Teile sowie Performance und Barrierefreiheit.
frontend-a11y
280kHilft deinem Agenten, Weboberflächen für alle zugänglich zu machen. Sorgt dafür, dass Websites und Apps gut mit Screenreadern und Tastaturnavigation funktionieren.
frontend-patterns
280kLässt deinen Agenten moderne Muster in der Frontend-Entwicklung anwenden. Optimiert Performance, verwaltet State und folgt Best Practices für React und Next.js.