fix: sync log platform art collision alignment
This commit is contained in:
parent
6133020a60
commit
aba87e9cb3
17
src/main.js
17
src/main.js
@ -7,6 +7,9 @@ const GROUND_Y = 628;
|
||||
const GROUND_SURFACE_Y = GROUND_Y - 4;
|
||||
const GROUND_ART_SCALE = 0.98;
|
||||
const GROUND_ART_SURFACE_OFFSET = 20;
|
||||
const LOG_FRAME_HEIGHT = 79;
|
||||
const LOG_ART_SURFACE_OFFSET = 17;
|
||||
const LOG_COLLIDER_HEIGHT = 16;
|
||||
|
||||
class ForestScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
@ -398,17 +401,23 @@ class ForestScene extends Phaser.Scene {
|
||||
[4680, 545], [4890, 505], [5100, 465]
|
||||
];
|
||||
|
||||
branchPositions.forEach(([x, y], index) => {
|
||||
// branchPositions store the intended walkable surface Y, not the
|
||||
// collider centre. The illustrated log's usable top edge is 17 source
|
||||
// pixels below its cropped frame top, so derive art + physics from the
|
||||
// same surface coordinate.
|
||||
branchPositions.forEach(([x, surfaceY], index) => {
|
||||
const scale = index % 3 === 0 ? 0.62 : 0.55;
|
||||
const visual = this.add.image(x, y + 15, 'terrain-sheet', 'log-platform')
|
||||
const visualY = surfaceY + ((LOG_FRAME_HEIGHT / 2 - LOG_ART_SURFACE_OFFSET) * scale);
|
||||
|
||||
const visual = this.add.image(x, visualY, 'terrain-sheet', 'log-platform')
|
||||
.setScale(scale)
|
||||
.setDepth(6);
|
||||
|
||||
const collider = this.add.rectangle(
|
||||
x,
|
||||
y,
|
||||
surfaceY + (LOG_COLLIDER_HEIGHT / 2),
|
||||
Math.max(130, visual.displayWidth * 0.82),
|
||||
16,
|
||||
LOG_COLLIDER_HEIGHT,
|
||||
0x000000,
|
||||
0
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user