✨ fix depth sorting for world objects by tileY
Fixes #31. All trees, rocks, seedlings and buildings now use tileY+5 as depth instead of a fixed value, so objects further down the screen always render in front of objects above them regardless of spawn order. Build ghost moved to depth 1000/1001. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@ export class BuildingSystem {
|
||||
|
||||
create(): void {
|
||||
this.ghost = this.scene.add.rectangle(0, 0, TILE_SIZE, TILE_SIZE, 0x00FF00, 0.35)
|
||||
this.ghost.setDepth(20)
|
||||
this.ghost.setDepth(1000)
|
||||
this.ghost.setVisible(false)
|
||||
this.ghost.setStrokeStyle(2, 0x00FF00, 0.8)
|
||||
|
||||
@@ -40,7 +40,7 @@ export class BuildingSystem {
|
||||
fontSize: '10px', color: '#ffffff', fontFamily: 'monospace',
|
||||
backgroundColor: '#000000aa', padding: { x: 3, y: 2 }
|
||||
})
|
||||
this.ghostLabel.setDepth(21)
|
||||
this.ghostLabel.setDepth(1001)
|
||||
this.ghostLabel.setVisible(false)
|
||||
this.ghostLabel.setOrigin(0.5, 1)
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ export class ResourceSystem {
|
||||
sprite.setOrigin(0.5, 0.75)
|
||||
}
|
||||
|
||||
sprite.setDepth(5)
|
||||
sprite.setDepth(node.tileY + 5)
|
||||
|
||||
const healthBar = this.scene.add.graphics()
|
||||
healthBar.setDepth(6)
|
||||
healthBar.setDepth(node.tileY + 6)
|
||||
healthBar.setVisible(false)
|
||||
|
||||
this.sprites.set(node.id, { sprite, node, healthBar })
|
||||
|
||||
@@ -110,7 +110,7 @@ export class TreeSeedlingSystem {
|
||||
const key = `seedling_${Math.min(s.stage, 2)}`
|
||||
const sprite = this.scene.add.image(x, y, key)
|
||||
.setOrigin(0.5, 0.85)
|
||||
.setDepth(5)
|
||||
.setDepth(s.tileY + 5)
|
||||
this.sprites.set(s.id, sprite)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user