Fixed cut_scene.
This commit is contained in:
parent
a6702edf16
commit
998e319d92
25
sound.py
25
sound.py
@ -8,9 +8,10 @@ Handles all audio functionality including:
|
||||
"""
|
||||
|
||||
import os
|
||||
import pyglet
|
||||
import random
|
||||
import re
|
||||
import pyglet
|
||||
import time
|
||||
from os.path import isfile, join
|
||||
from pyglet.window import key
|
||||
|
||||
@ -235,27 +236,33 @@ class Sound:
|
||||
self.stop_all_sounds()
|
||||
if self.currentBgm:
|
||||
self.currentBgm.pause()
|
||||
|
||||
|
||||
if soundName not in self.sounds:
|
||||
return
|
||||
|
||||
|
||||
# Create and configure the player
|
||||
player = pyglet.media.Player()
|
||||
player.queue(self.sounds[soundName])
|
||||
player.volume = self.sfxVolume * self.masterVolume
|
||||
|
||||
|
||||
# Start playback
|
||||
player.play()
|
||||
|
||||
# Wait for completion or skip using game's wait_for_completion method
|
||||
# Make sure to give pyglet enough cycles to start playing
|
||||
startTime = time.time()
|
||||
duration = self.sounds[soundName].duration
|
||||
pyglet.clock.tick()
|
||||
|
||||
# Wait for completion or skip
|
||||
interrupted = self.game.wait_for_completion(
|
||||
lambda: not player.playing
|
||||
lambda: not player.playing or (time.time() - startTime) >= duration
|
||||
)
|
||||
|
||||
|
||||
# Ensure cleanup
|
||||
player.pause()
|
||||
if interrupted:
|
||||
player.pause()
|
||||
player.delete()
|
||||
|
||||
|
||||
# Resume background music if it was playing
|
||||
if self.currentBgm:
|
||||
self.currentBgm.play()
|
||||
|
Loading…
x
Reference in New Issue
Block a user