melonjs-display-and-scaling
하는 일
melonJS 게임의 크기와 선명도를 화면에서 조절하는 설정을 설명합니다. 게임이 흐리게 보이거나 브라우저 창에 맞지 않는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓고해상도 화면에서 melonJS 게임이 흐리거나 부드럽게 보일 때.
- ✓melonJS 게임이 잘리거나 개발자가 원하는 방식으로 페이지를 채우지 않을 때.
- ✓개발자가 브라우저 게임의 픽셀 아트를 위해 픽셀 단위로 정확한 크기를 원할 때.
스킬 링크
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-display-and-scaling/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 melonJS 픽셀 아트가 흐리게 보이고 창에 맞지 않습니다. 어떤 설정을 바꿔야 하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 설정을 디자인 크기, 확대·축소 방식, 반올림, 텍스처 필터링처럼 역할별로 나누고, 각 문제에 맞춰 무엇을 바꿔야 하는지 설명합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
디자인 해상도란 무엇인가요?
게임이 그려지는 고정 크기이며, 이것이 창에 맞게 확대·축소됩니다.
픽셀 아트를 선명하게 만들려면 어떻게 하나요?
정수 배율과 nearest-neighbor 텍스처 필터링을 일반적인 선택으로 언급합니다.
움직임이 고르지 않게 보이는 이유는 무엇인가요?
프레임 사이의 움직임을 일정하게 만드는 동기화 설정을 언급합니다.
상세 정보
작성자의 원본 설명
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
인기도
- GitHub 스타
- 6.4k
- 순위
- #14200
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
melonjs-20-migration
6.4k에이전트가 melonJS 20 버전에 맞는 게임 코드를 작성하고, 필수 비동기 시작 방식 등 이전 버전의 오래된 메서드를 피하도록 돕습니다.
melonjs-3d-assets
6.4k에이전트가 glTF, GLB, OBJ 같은 3D 모델 파일을 melonJS 브라우저 게임에 불러오고, 크기와 조명 옵션을 설정하도록 돕습니다.
melonjs-3d
6.4k에이전트가 melonJS 브라우저 게임에서 카메라, 메시, 조명, 깊이를 포함한 3D 또는 2.5D 장면을 엔진 고유의 축 규칙에 맞게 만들도록 돕습니다.
melonjs-audio
6.4k에이전트가 melonJS 게임에 효과음과 배경 음악을 추가하고, 오디오 설정, 음량 조절, 공간 음향까지 다루도록 돕습니다.