melonjs-display-and-scaling
Ce qu’il fait
Ce guide explique les réglages qui contrôlent la taille et la netteté d'un jeu melonJS à l'écran. Il s'adresse aux développeurs dont le jeu paraît flou ou ne s'adapte pas à la fenêtre du navigateur.
Quand l’utiliser
- ✓Quand un jeu melonJS paraît flou sur un écran à haute résolution.
- ✓Quand un jeu melonJS est rogné ou ne remplit pas la page comme le développeur le souhaite.
- ✓Quand un développeur veut un dimensionnement pixel par pixel pour du pixel art dans un jeu navigateur.
Lien du skill
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-display-and-scaling/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Mon pixel art melonJS est flou et ne s'adapte pas à la fenêtre. Quels réglages dois-je modifier ?”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
Le skill répartit les réglages selon leur fonction, comme la résolution de conception, la méthode de mise à l'échelle, l'arrondi et le filtrage des textures, et explique lequel modifier pour chaque problème.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
Display and scaling
Seven settings decide how a game looks on screen, and they are easy to get individually right and collectively wrong. This is what each one actually does, and which one to reach for.
The four jobs
A pixel travels from your source art to a physical pixel through four separate decisions. Knowing which setting owns which is most of the work.
| job | setting | what it decides |
|---|---|---|
| how big the frame is drawn | width/height on Application |
the design resolution everything is authored against |
| how it uses the space | scale, scaleMethod, scaleTarget |
fit, fill, stretch, and what it measures to decide |
| may the factor be fractional | scaleRounding |
whole device pixels per source pixel, or any factor |
| how a texture is sampled | antiAlias, textureFilter |
nearest or linear, and the CSS upscale filter |
subPixel is a fifth, orthogonal to all of them: it decides whether a
renderable may sit on a fractional position WITHIN the frame. syncToDisplay
is about the frames in a row rather than one frame: whether motion advances
by the same amount on each.
Design resolution
const app = new Application(480, 270, { scale: "auto" });
The game is drawn at 480x270 whatever the window is, and the canvas is scaled to the container. Everything in world coordinates is in those units. This is the usual arrangement: author once, scale to whatever you are given.
scale and scaleMethod
scale: "auto" turns on automatic scaling; a number is a fixed multiplier and
scaleMethod is then ignored.
scaleMethod decides how the available space is used:
"fit"keeps the design resolution and the aspect ratio, scaling to the largest factor that fits. Leftover space becomes margin. This is the one to use when the game is authored for a fixed frame."fill-min"/"fill-max"keep the aspect ratio but RESIZE the renderer, so the design resolution changes with the window and the game sees more or less of the world."flex","flex-width","flex-height"resize the renderer on one or both axes."stretch"scales each axis independently, so the aspect ratio is not preserved and circles become ovals."manual"does nothing automatic.
The distinction that matters: fit scales a fixed frame; everything else
changes how much of the world is visible. A game whose layout assumes a
known frame wants fit.
scaleTarget: what gets measured
Automatic scaling measures the parent of the element the canvas is mounted in, not the element itself. If that grandparent is not the box you meant, the canvas is sized wrongly, and the failure is quiet.
The case that bites: a canvas container that is position: fixed or
absolute contributes no height to its parent, so the parent measures only
whatever else is in it. If that parent is <body>, the engine falls back to
the window size and the canvas ends up larger than the box it lives in,
cropped by whatever sits above it.
new Application(1024, 576, {
parent: "screen",
scale: "auto",
// measure THIS, rather than guessing from the DOM shape
scaleTarget: document.getElementById("stage"),
});
Either name the element with scaleTarget, or give the canvas container a
parent whose box is the area you want filled. If the canvas is cropped or
overflows on resize, this is the first thing to check.
scaleRounding: whole device pixels
new Application(480, 270, {
scale: "auto",
scaleMethod: "fit",
scaleRounding: "integer", // default "fractional"
});
"fractional" fills the container exactly, at whatever factor that takes. A
480 wide design in a 1280 wide container is scaled by 2.667, so some source
pixels cover three screen pixels and some cover two. Pixel art shows this as
uneven glyph stems and shimmering edges, and browsers resolve the unevenness
differently, so the same scene can look crisp in one and soft in another.
"integer" rounds the factor DOWN so every source pixel covers the same whole
number of device pixels, and letterboxes with the space left over. That trade,
crisp pixels for black bars, is the whole decision.
What it costs
More than "some letterboxing", and the size of it is decided by
devicePixelRatio as much as by the window. A higher ratio has more device
pixels to round among, so it lands closer to the factor it wanted. For a
480x270 design, which is exactly a quarter of 1920x1080:
| container | ratio | f
Questions fréquentes
Qu'est-ce qu'une résolution de conception ?
C'est la taille fixe à laquelle le jeu est dessiné, puis mise à l'échelle pour tenir dans la fenêtre.
Comment obtenir un pixel art net ?
Le skill cite la mise à l'échelle entière et le filtrage des textures au plus proche voisin comme choix habituels.
Pourquoi le mouvement paraît-il irrégulier ?
Le skill mentionne un réglage de synchronisation pour un mouvement régulier entre les images.
Détails
Description originale de l’auteur
Use this skill when a melonJS game looks blurry, soft, shimmering or cropped, or when choosing how the canvas fills its page. Covers the design resolution, scale and scaleMethod, scaleTarget, scaleRounding for pixel-perfect integer scaling, antiAlias, textureFilter and linear-mipmap for what is drawn small, subPixel, syncToDisplay for steady motion, devicePixelRatio, and which setting does which job. Triggers on: blurry, soft, fuzzy, shimmering, pixel art, pixel perfect, crisp, nearest, linear, scale, scaleMethod, scaleTarget, scaleRounding, integer scaling, antiAlias, textureFilter, linear-mi
repo: melonjs/melonJS
Popularité
- Étoiles GitHub
- 6.4k
- Position au classement
- #14200
- Licence
- MIT
- Mis à jour
- 02/11/2026
Commentaires
- …
Autres skills de ce dépôt
melonjs-20-migration
6.4kAide votre agent à écrire du code de jeu melonJS pour la version 20 et à éviter les méthodes obsolètes des versions précédentes, comme le démarrage asynchrone obligatoire.
melonjs-3d-assets
6.4kAide votre agent à charger des modèles 3D comme les fichiers glTF, GLB et OBJ dans un jeu melonJS, avec des options d'échelle et d'éclairage.
melonjs-3d
6.4kAide votre agent à construire des scènes 3D ou 2,5D dans un jeu melonJS, avec les caméras, les maillages, les lumières et la profondeur, selon les règles d'axes du moteur.
melonjs-audio
6.4kAide votre agent à ajouter des effets sonores et de la musique à un jeu melonJS, avec la configuration audio, les pistes de fond, le réglage du volume et le son spatial.
Skills similaires
diffs
394kPermet à votre agent de produire un diff réel et partageable de vos modifications, sous forme de lien ou d'image, plutôt qu'un résumé écrit à la main.
coding-agent
394kAide votre agent à confier une tâche de programmation plus importante à Codex, Claude Code ou OpenCode comme travailleur en arrière-plan, puis à suivre sa progression.
gh-issues
394kAide votre agent à trouver des tickets GitHub, choisir ceux à traiter et ouvrir des pull requests avec des correctifs, y compris le suivi des commentaires de relecture.