What problem does it solve?
This skill solves inconsistent canvas sizing and broken layout when building a responsive Phaser 4 game for different screen sizes, aspect ratios, and fullscreen states.
Core Features & Use Cases
- ScaleManager-based responsive scaling: Apply Phaser ScaleManager logic to keep world/camera sizing consistent while the canvas is visually scaled by CSS.
- Mode coverage for real scenarios: Use FIT for letterboxed layouts, ENVELOP for full-bleed covered layouts, RESIZE for true 1:1 pixel canvases, and NONE when you manage sizing yourself.
- Centering and input correctness: Enable auto-centering (margins) and keep coordinate mapping stable via ScaleManager’s displayScale.
- Fullscreen and orientation handling: Listen for fullscreen enter/leave and orientation changes, and optionally lock orientation on supported mobile browsers.
Quick Start
Configure your Phaser game with a parent element, set scale.mode to Phaser.Scale.FIT, enable scale.autoCenter to Phaser.Scale.CENTER_BOTH, and use the ScaleManager’s resize/orientation/fullscreen events to update cameras and UI when the viewport changes.