Game Setup And ConfigSAFE
Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
Overview
Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
d14f4c86f869OBSERVED · 2026-10-28What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
---
name: game-setup-and-config
description: "Use this skill when creating a new Phaser 4 game instance or configuring GameConfig options. Covers renderer selection, canvas setup, scaling, pixel art, FPS settings, boot sequence, and all config sub-objects. Triggers on: new Phaser.Game, GameConfig, game setup, renderer, pixel art, FPS."
---
# Game Setup and Config
> How to create a Phaser.Game instance with the right GameConfig options for renderer, scaling, pixel art, FPS, and canvas placement.
**Key source paths:** `src/core/Game.js`, `src/core/Config.js`, `src/core/typedefs/GameConfig.js`, `src/const.js`, `src/scale/const/`
**Related skills:** ../scenes/SKILL.md, ../loading-assets/SKILL.md, ../scale-and-responsive/SKILL.md
## Quick Start
The simplest possible Phaser 4 game -- a single scene with the default 1024×768 canvas:
```js
class MyScene extends Phaser.Scene {
preload() {
this.load.image('logo', 'assets/logo.png');
}
create() {
this.add.image(400, 300, 'logo');
}
}
const config = {
type: Phaser.AUTO,
scene: MyScene
};
const game = new Phaser.Game(config);
```
`new Phaser.Game(config)` triggers the entire boot sequence: config parsing (`Config`), renderer creation, DOM insertion, and the game loop (`TimeStep`). The game waits for `DOMContentLoaded` before booting.
## Core Concepts
### Boot Sequence (src/core/Game.js)
1. `new Phaser.Game(config)` -- parses config into a `Phaser.Core.Config` instance.
2. Creates global managers: `AnimationManager`, `TextureManager`, `CacheManager`, `InputManager`, `SceneManager`, `ScaleManager`, `SoundManager`, `TimeStep`, `PluginManager`.
3. Waits for `DOMContentLoaded`, then calls `boot()`.
4. `boot()` creates the renderer (`CreateRenderer`), adds the canvas to the DOM (`AddToDOM`), prints the debug header, emits `BOOT`.
5. Once textures are ready (`TextureManager` emits `READY`), emits `READY` then calls `start()`.
6. `start()` begins the `TimeStep` loop, sets up the `VisibilityHandler`, calls `config.postBoot`.
### Config Parsing (src/core/Config.js)
The `Config` constructor reads a flat `GameConfig` object and resolves defaults. Some properties can be specified at top level OR nested inside sub-objects (e.g., `width` can be top-level or under `scale.width`). The `scale` sub-object takes priority when both are present.
Render properties can likewise be top-level shortcuts (e.g., `pixelArt: true`) or nested under `render`.
### Renderer Constants (src/const.js)
| Constant | Value | Behavior |
|---|---|---|
| `Phaser.AUTO` | `0` | WebGL if supported, else falls back to Canvas |
| `Phaser.CANVAS` | `1` | Force Canvas renderer |
| `Phaser.WEBGL` | `2` | Force WebGL -- no fallback if unsupported |
| `Phaser.HEADLESS` | `3` | No renderer -- DOM still required. For unit testing only |
Set via `config.type`. Default is `Phaser.AUTO`.
## Common Patterns
### Pixel Art Game
When `pixelArt` is `true`, Config automatically sets `antialias: false`, `antialiasGL: false`, and `roundPixels: true`.
```js
const config = {
type: Phaser.AUTO,
width: 320,
height: 240,
pixelArt: true,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
zoom: Phaser.Scale.ZOOM_2X
},
scene: MyScene
};
```
### Smooth Pixel Art (WebGL only)
Preserves blocky pixels but smooths edges between them when scaled up:
```js
const config = {
type: Phaser.WEBGL,
width: 320,
height: 240,
smoothPixelArt: true,
scene: MyScene
};
```
When `smoothPixelArt` is `true`, Config sets `antialias: true`, `antialiasGL: true`, and `pixelArt: false`.
### Full-Window Responsive Game
```js
const config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.RESIZE,
parent: 'game-container',
width: '100%',
height: '100%'
},
scene: MyScene
};
```
### Fixed Aspect Ratio with FIT
```js
const config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.FIT,
parent: 'game-container',
autoCenter: Phaser.Scale.CENTER_BOTH,
width: 1280,
height: 720,
min: { width: 640, height: 360 },
max: { width: 1920, height: 1080 }
},
backgroundColor: '#2d2d2d',
scene: MyScene
};
```
### Custom FPS Limit
```js
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
fps: {
target: 60,
limit: 30,
forceSetTimeOut: false,
smoothStep: true
},
scene: MyScene
};
```
### Transparent Canvas Over HTML
```js
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
transparent: true,
parent: 'game-container',
scene: MyScene
};
```
When `transparent` is `true`, `backgroundColor` is forced to `0x000000` with alpha `0`.
### Pre-existing Canvas Element
```js
const canvas = document.getElementById('my-canvas');
const config = {
type: Phaser.WEBGL,
canvas: canvas,
width: 800,
height: 600,
scene: MyScene
};
```
### Multiple Scenes
```js
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: [BootScene, PreloadScene, MenuScene, GameScene],
physics: {
default: 'arcade',
arcade: { gravity: { y: 300 } }
}
};
```
Only the first scene starts automatically. Others start only if they have `{ active: true }` in their scene config. See ../scenes/SKILL.md.
### Boot Callbacks
```js
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
callbacks: {
preBoot: function (game) {
// Runs before Phaser boots. Game systems not yet available.
},
postBoot: function (game) {
// Runs after boot. All systems ready, game loop starting.
}
},
scene: MyScene
};
```
### Disabling Input Subsystems
```js
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
input: {
keyboard: true,
mouse: true,
touch: false,
Trust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | PASS |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (0)
No findings outside the package's declared scope.
Gates applied: no_behavioural_pass.
d14f4c86f869full audit observations/trust-audit/skill/phaserjs__game-setup-and-config.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-28 | d14f4c86f869 | SAFE | B | 89 | first audit |
Questions
What does the game-setup-and-config — phaserjs/phaser skill do?
Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
Is game-setup-and-config — phaserjs/phaser safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can game-setup-and-config — phaserjs/phaser access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
How current is this page?
The grade is for one exact copy of the source (d14f4c86f869), read on 2026-10-28. The repository is watched, and a new audit runs when it changes — this is the first audit.
Add this badge to your README
Shows this page's audit result and links back to it. It updates when the audit does.
[](https://modelsatlas.com/skills/phaserjs/game-setup-and-config/)
Not your listing, or something out of date? Claim or update your listing.