本文整理汇总了Python中pygame.mixer.Sound.fadeout方法的典型用法代码示例。如果您正苦于以下问题:Python Sound.fadeout方法的具体用法?Python Sound.fadeout怎么用?Python Sound.fadeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.mixer.Sound
的用法示例。
在下文中一共展示了Sound.fadeout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: thunder
# 需要导入模块: from pygame.mixer import Sound [as 别名]
# 或者: from pygame.mixer.Sound import fadeout [as 别名]
def thunder(self, inc):
wait = random.randint(0, 2+inc)
while (self._last == wait):
wait = random.randint(0, 2+inc)
self._last = wait
print "intensity:", wait
thunder = Sound("%s/thunder_0%d.wav" % (self._data_folder, wait))
if wait < 6:
self.lightning.set_C(ON)
self.lightning.send()
time.sleep(random.uniform(0.5, 1.5))
self.lightning.set_C(OFF)
self.lightning.send()
time.sleep(wait)
if wait < 6:
self.lightning.set_B(OFF)
self.lightning.send()
thunder.play()
if wait < 6:
time.sleep(0.3)
self.lightning.set_B(ON)
self.lightning.send()
time.sleep(thunder.get_length()-0.3)
thunder.fadeout(200)
time.sleep(wait)
示例2: __init__
# 需要导入模块: from pygame.mixer import Sound [as 别名]
# 或者: from pygame.mixer.Sound import fadeout [as 别名]
class Sound:
"""Class wrapping ``pygame.mixer.Sound`` with the ability to enable/disable sound globally
Use this instead of ``pygame.mixer.Sound``. The interface is fully transparent.
"""
def __init__(self, source):
if config.SOUND:
self.sound = OldSound(source)
def play(self, loops=0, maxtime=0, fade_ms=0):
if config.SOUND:
self.sound.play(loops, maxtime, fade_ms)
def stop(self):
if config.SOUND:
self.sound.stop()
def fadeout(self, time):
if config.SOUND:
self.sound.fadeout(time)
def set_volume(self, value):
if config.SOUND:
self.sound.set_volume(value)
def get_volume(self):
if config.SOUND:
return self.sound.get_volume()
def get_num_channels(self):
if config.SOUND:
return self.sound.get_num_channels()
def get_length(self):
if config.SOUND:
return self.get_length()
def get_raw(self):
if config.SOUND:
return self.sound.get_raw()