我想知道如何选择随机声音并以OOP方式播放事件。我原来的计划是在我的资源加载器类中有一个列表,并让它迭代。我唯一的问题是当我尝试实现这个时,我的代码会不断地破坏所有内容。你们会怎么做呢?
答案 0 :(得分:0)
class SoundManager:
sounds = [] # list of sound objects
@staticmethod
def playRandom():
random.choice(SoundManager.sounds).play()