Cleaned sound composable code

This commit is contained in:
2025-02-06 22:35:54 +01:00
parent fb3a59aa59
commit 838610d041
4 changed files with 97 additions and 60 deletions

View File

@ -43,6 +43,9 @@ const handlePositionUpdate = (newValues: any, oldValues: any) => {
}
}
/**
* Plays walk sound when character is moving
*/
watch(
() => props.mapCharacter.isMoving,
(newValue) => {
@ -54,6 +57,9 @@ watch(
}
)
/**
* Plays attack animation and sound when character is attacking
*/
watch(
() => props.mapCharacter.isAttacking,
(newValue) => {
@ -67,6 +73,9 @@ watch(
}
)
/**
* Handles position updates and movement delay
*/
watch(
() => ({
positionX: props.mapCharacter.character.positionX,
@ -82,7 +91,6 @@ watch(
onMounted(async () => {
await initializeSprite()
if (props.mapCharacter.character.id === gameStore.character!.id) {
mapStore.setCharacterLoaded(true)
scene.cameras.main.startFollow(characterContainer.value as Phaser.GameObjects.Container)