Fixed cut_scene.
This commit is contained in:
parent
a6702edf16
commit
998e319d92
13
sound.py
13
sound.py
@ -8,9 +8,10 @@ Handles all audio functionality including:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import pyglet
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import pyglet
|
import time
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
from pyglet.window import key
|
from pyglet.window import key
|
||||||
|
|
||||||
@ -247,12 +248,18 @@ class Sound:
|
|||||||
# Start playback
|
# Start playback
|
||||||
player.play()
|
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(
|
interrupted = self.game.wait_for_completion(
|
||||||
lambda: not player.playing
|
lambda: not player.playing or (time.time() - startTime) >= duration
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure cleanup
|
# Ensure cleanup
|
||||||
|
if interrupted:
|
||||||
player.pause()
|
player.pause()
|
||||||
player.delete()
|
player.delete()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user