diff --git a/src/components/screens/Game.vue b/src/components/screens/Game.vue index 64020f0..0c989a7 100644 --- a/src/components/screens/Game.vue +++ b/src/components/screens/Game.vue @@ -30,9 +30,10 @@ import Map from '@/components/game/map/Map.vue' import { useGameComposable } from '@/composables/useGameComposable' import { useGameStore } from '@/stores/gameStore' import { Game, Scene } from 'phavuer' +import { onMounted } from 'vue' const gameStore = useGameStore() -const { playSound } = useGameComposable() +const { playSound, stopSound } = useGameComposable() const gameConfig = { name: config.name, @@ -68,4 +69,8 @@ function preloadScene(scene: Phaser.Scene) { scene.load.image('blank_tile', '/assets/map/blank_tile.png') scene.load.image('waypoint', '/assets/waypoint.png') } + +onMounted(() => { + stopSound('/assets/music/intro.mp3') +}) diff --git a/src/composables/useGameComposable.ts b/src/composables/useGameComposable.ts index a94d67f..837a224 100644 --- a/src/composables/useGameComposable.ts +++ b/src/composables/useGameComposable.ts @@ -1,6 +1,6 @@ -export function useGameComposable() { - const activeSounds: { [key: string]: HTMLAudioElement } = {} +const activeSounds: { [key: string]: HTMLAudioElement } = {} +export function useGameComposable() { const playSound = (sound: string, loop: boolean = false, ignoreIfPlaying: boolean = false) => { // If sound is already playing and we want to ignore if (ignoreIfPlaying && activeSounds[sound] && !activeSounds[sound].paused) {