选择随机声音Pygame

时间:2015-03-04 21:54:56

标签: python pygame

我想知道如何选择随机声音并以OOP方式播放事件。我原来的计划是在我的资源加载器类中有一个列表,并让它迭代。我唯一的问题是当我尝试实现这个时,我的代码会不断地破坏所有内容。你们会怎么做呢?

1 个答案:

答案 0 :(得分:0)

class SoundManager:
    sounds = [] # list of sound objects

    @staticmethod
    def playRandom():
        random.choice(SoundManager.sounds).play()