Fixed object moving when its not supposed to
This commit is contained in:
@ -39,8 +39,8 @@ const props = defineProps<{
|
||||
const previewPosition = ref({ x: 0, y: 0 })
|
||||
|
||||
const previewPlacedMapObject = computed(() => ({
|
||||
id: mapEditor.selectedMapObject.value?.id ?? uuidv4(),
|
||||
mapObject: mapEditor.selectedMapObject.value?.id,
|
||||
id: mapEditor.selectedMapObject.value!.id,
|
||||
mapObject: mapEditor.selectedMapObject.value!,
|
||||
isRotated: false,
|
||||
positionX: previewPosition.value.x,
|
||||
positionY: previewPosition.value.y
|
||||
@ -118,13 +118,14 @@ function moveMapObject(id: string, map: MapT) {
|
||||
}
|
||||
|
||||
scene.input.on(Phaser.Input.Events.POINTER_MOVE, handlePointerMove)
|
||||
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
|
||||
|
||||
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
||||
scene.input.off(Phaser.Input.Events.POINTER_MOVE, handlePointerMove)
|
||||
|
||||
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
||||
if (!tile) return
|
||||
|
||||
console.log(id)
|
||||
map.placedMapObjects.map((placed) => {
|
||||
if (placed.id === id) {
|
||||
placed.positionX = tile.x
|
||||
@ -132,10 +133,9 @@ function moveMapObject(id: string, map: MapT) {
|
||||
}})
|
||||
|
||||
mapEditor.movingPlacedObject.value = null
|
||||
emit('updateAndCommit', map)
|
||||
scene.input.off(Phaser.Input.Events.POINTER_UP, handlePointerUp)
|
||||
}
|
||||
emit('updateAndCommit', map)
|
||||
|
||||
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
|
||||
}
|
||||
|
||||
function rotatePlacedMapObject(id: string, map: MapT) {
|
||||
|
Reference in New Issue
Block a user