Depth sorting
This commit is contained in:
parent
cd1daf9345
commit
d25100c810
@ -35,8 +35,6 @@ const imageProps = computed(() => ({
|
||||
originY: props.placedMapObject.mapObject.originY
|
||||
}))
|
||||
|
||||
// ... existing code ...
|
||||
|
||||
function calculateObjectPlacement(mapObj: PlacedMapObject) : {x: number; y: number} {
|
||||
let position = tileToWorldXY(props.tileMapLayer, mapObj.positionX, mapObj.positionY)
|
||||
|
||||
@ -46,8 +44,6 @@ function calculateObjectPlacement(mapObj: PlacedMapObject) : {x: number; y: numb
|
||||
}
|
||||
}
|
||||
|
||||
// ... existing code ...
|
||||
|
||||
onMounted(async () => {
|
||||
await loadTexture(scene, {
|
||||
key: props.placedMapObject.mapObject.id,
|
||||
|
@ -68,11 +68,11 @@ export function createTileArray(width: number, height: number, tile: string = 'b
|
||||
}
|
||||
|
||||
export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0, isCharacter: boolean = false) => {
|
||||
const baseDepth = Math.max(positionX, positionY)
|
||||
const baseDepth = (positionX + positionY) * 1000
|
||||
if (isCharacter) {
|
||||
return baseDepth // @TODO: Fix collision, this is a hack
|
||||
return baseDepth + 500 // Characters should always be above objects at the same position
|
||||
}
|
||||
return (baseDepth + height) / (config.tile_size.width * 2)
|
||||
return baseDepth + (width + height) / 4
|
||||
}
|
||||
|
||||
async function getTiles(tiles: TileT[], scene: Phaser.Scene) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user