Python Pygame设置目标为列表时的音量 我正在做一个游戏,我有一个列表中的这些爆炸(EXPL),所以每次都不是一样的声音。我正在使用random.choice来“控制”输出 expl_sound = [] for snd in ['expl.wav', 'expl1.wav', "expl2.wav"]: expl_sound.append(pygame.mixer.Sound(path.join(snd_folder, snd)))
但是当我去设置声音列表的音量时,它会弹出这个错误消息Python Pygame设置目标为列表时的音量 我正在做一个游戏,我有一个列表中的这些爆炸(EXPL),所以每次都不是一样的声音。我正在使用random.choice来“控制”输出 expl_sound = [] for snd in ['expl.wav', 'expl1.wav', "expl2.wav"]: expl_sound.append(pygame.mixer.Sound(path.join(snd_folder, snd))),python,python-3.x,pygame,Python,Python 3.x,Pygame,但是当我去设置声音列表的音量时,它会弹出这个错误消息 Traceback (most recent call last): File "C:\Users\wep43\Desktop\Python Games\Pygames Tutorial\Pygame Shmup.py", line 311, in <module> expl_sound.set_volume(0.1) AttributeError: 'list' object has no
Traceback (most recent call last):
File "C:\Users\wep43\Desktop\Python Games\Pygames Tutorial\Pygame Shmup.py", line 311, in <module>
expl_sound.set_volume(0.1)
AttributeError: 'list' object has no attribute 'set_volume'
回溯(最近一次呼叫最后一次):
文件“C:\Users\wep43\Desktop\Python Games\Pygames Tutorial\Pygame Shmup.py”,第311行,在
解释声音。设置音量(0.1)
AttributeError:“list”对象没有属性“set\u volume”
我不能让它不吐出这个信息
我希望我的问题是有道理的,否则只需询问更多信息是类的实例方法,但是expl\u sound
是pygame.mixer.sound
对象的列表。因此,必须分别为列表中的每个(声音)元素设置音量:
expl_声音中snd的:
snd.set_体积(0.1)