1
0
forked from noxious/client

Bug fixes for updating zone width and height (realtime now), removed redundant code from camera composable, improved zone editor tool modal logics.

This commit is contained in:
2024-09-14 21:40:42 +02:00
parent 717fb1646c
commit bb08aaa9bc
9 changed files with 98 additions and 85 deletions

View File

@ -5,35 +5,17 @@ export function useCameraControls(scene: Phaser.Scene): any {
const gameStore = useGameStore()
const camera = ref(scene.cameras.main)
const isDragging = ref(false)
let pointerDownTimer: number | null | NodeJS.Timeout = null
let pointerUpTimer: number | null | NodeJS.Timeout = null
const DRAG_DELAY = 150
const MOVE_RESET_DELAY = 100
function onPointerDown(pointer: Phaser.Input.Pointer) {
if (pointer.event instanceof MouseEvent || pointer.event.shiftKey) {
pointerDownTimer = setTimeout(() => {
isDragging.value = true
gameStore.setMovingCamera(true)
}, DRAG_DELAY)
isDragging.value = true
gameStore.setMovingCamera(true)
}
}
function onPointerUp() {
if (pointerDownTimer) {
clearTimeout(pointerDownTimer)
pointerDownTimer = null
}
isDragging.value = false
if (pointerUpTimer) {
clearTimeout(pointerUpTimer)
}
pointerUpTimer = setTimeout(() => {
gameStore.setMovingCamera(false)
}, MOVE_RESET_DELAY)
gameStore.setMovingCamera(false)
}
scene.input.on(Phaser.Input.Events.POINTER_DOWN, onPointerDown)
@ -43,4 +25,4 @@ export function useCameraControls(scene: Phaser.Scene): any {
camera,
isDragging
}
}
}