fix: sync ground art collision alignment

This commit is contained in:
Admin 2026-09-19 07:58:10 +00:00
parent 71ce5a00e9
commit 6133020a60

View File

@ -4,6 +4,9 @@ import './style.css';
const WORLD_WIDTH = 5600;
const WORLD_HEIGHT = 720;
const GROUND_Y = 628;
const GROUND_SURFACE_Y = GROUND_Y - 4;
const GROUND_ART_SCALE = 0.98;
const GROUND_ART_SURFACE_OFFSET = 20;
class ForestScene extends Phaser.Scene {
constructor() {
@ -364,14 +367,25 @@ class ForestScene extends Phaser.Scene {
createWorld() {
this.platforms = this.physics.add.staticGroup();
const ground = this.add.rectangle(WORLD_WIDTH / 2, GROUND_Y + 46, WORLD_WIDTH, 100, 0x263c2d, 0);
// Keep the physics plane and the illustrated grass line on the exact same Y.
// In ground-main the continuous walkable grass line is 20 source pixels
// below the cropped frame top.
const ground = this.add.rectangle(
WORLD_WIDTH / 2,
GROUND_SURFACE_Y + 50,
WORLD_WIDTH,
100,
0x263c2d,
0
);
this.physics.add.existing(ground, true);
this.platforms.add(ground);
const groundArtY = GROUND_SURFACE_Y - (GROUND_ART_SURFACE_OFFSET * GROUND_ART_SCALE);
for (let x = 165; x < WORLD_WIDTH + 340; x += 320) {
this.add.image(x, GROUND_Y - 5, 'terrain-sheet', 'ground-main')
this.add.image(x, groundArtY, 'terrain-sheet', 'ground-main')
.setOrigin(0.5, 0)
.setScale(0.98)
.setScale(GROUND_ART_SCALE)
.setDepth(3);
}