Y-based depth sorting for world objects (trees, buildings, rocks) #31
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
All world objects use fixed depth values:
Because depth is fixed, draw order depends on spawn order instead of Y position. This causes visible glitches — e.g. a forester hut trunk drawn over the canopy of a tree on the tile below it.
Fix
Use
tileY-based depth for all world objects so Phaser sorts them correctly:ResourceSystem: sprite depth =tileY + 5, health bar depth =tileY + 6TreeSeedlingSystem: sprite depth =tileY + 5GameScene.renderPersistentObjects: building depth =tileY + 5(chest, bed, forester hut); stockpile zone stays at 4BuildingSystem: ghost + label moved to depth 1000/1001 so they always render on topResult
Objects further down the screen (higher Y) correctly render in front of objects above them, regardless of spawn order.