1
0
forked from noxious/client

Added more SFX logic

This commit is contained in:
2025-02-06 21:43:09 +01:00
parent 6383320e8c
commit 12735756d7
5 changed files with 47 additions and 5 deletions

View File

@ -8,7 +8,6 @@
</template>
<script lang="ts" setup>
import { Direction } from '@/application/enums'
import { type MapCharacter } from '@/application/types'
import CharacterHair from '@/components/game/character/partials/CharacterHair.vue'
import ChatBubble from '@/components/game/character/partials/ChatBubble.vue'
@ -30,7 +29,7 @@ const mapStore = useMapStore()
const scene = useScene()
const { characterContainer, characterSprite, currentPositionX, currentPositionY, isometricDepth, isFlippedX, updatePosition, playAnimation, calcDirection, updateSprite, initializeSprite, cleanup } = useCharacterSpriteComposable(scene, props.tileMap, props.mapCharacter)
const { playSound } = useGameComposable()
const { playSound, stopSound } = useGameComposable()
const handlePositionUpdate = (newValues: any, oldValues: any) => {
if (!newValues) return
@ -54,7 +53,6 @@ watch(
}),
(oldValues, newValues) => {
handlePositionUpdate(oldValues, newValues)
if (props.mapCharacter.isAttacking) {
// Play attack animation
playAnimation('attack')
@ -66,6 +64,17 @@ watch(
}
)
watch(
() => props.mapCharacter.isMoving,
(newValue) => {
if (newValue) {
playSound('/assets/sounds/walk.mp3', true, true)
} else {
stopSound('/assets/sounds/walk.mp3')
}
}
)
onMounted(async () => {
await initializeSprite()