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:
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user