我现在已经有了它的工作但是时间延迟有一个更好的方法,因为我想要两个不同的脚本工作我希望这些按顺序播放并让我的图像按顺序出现并且图像是一个很长的脚本他们也有时间延迟.
#!/usr/bin/env python
import pygame
pygame.mixer.init()
pygame.mixer.pre_init(44100, -16, 2, 2048)
pygame.init()
print "hey I finaly got this working!"
sounda= pygame.mixer.Sound('D:/Users/John/Music/Music/FUN.OGG')
soundb= pygame.mixer.Sound('D:/Users/John/Music/Music/Still Alive.OGG')
soundc= pygame.mixer.Sound('D:/Users/John/Music/Music/turret.OGG')
soundd= pygame.mixer.Sound('D:/Users/John/Music/Music/portalend.OGG')
sounda.play()
pygame.time.delay(11000)
soundb.play()<P>
pygame.time.delay(180000)
soundc.play()
pygame.time.delay(90000)
soundd.play()
Run Code Online (Sandbox Code Playgroud)
你检查了pygame.Mixer模块吗?默认情况下,您可以同时播放8首歌曲
如果您使用pygame.mixer.music,那么您当时只能播放一首歌曲.
如果你使用pygame.mixer.sound,那么你当时最多可以播放8首歌曲.
在音乐模块是这里串流音乐(它不会立刻加载所有的音乐文件).
该声音模块是在这里玩游戏型动物中的声音(声音在完全加载到内存中).
因此,在您的示例中,如果您想同时播放4首歌曲:
import pygame
pygame.mixer.init()
pygame.mixer.pre_init(44100, -16, 2, 2048)
pygame.init()
print "hey I finaly got this working!"
sounds = []
sounds.append(pygame.mixer.Sound('D:/Users/John/Music/Music/FUN.OGG'))
sounds.append(pygame.mixer.Sound('D:/Users/John/Music/Music/Still Alive.OGG'))
sounds.append(pygame.mixer.Sound('D:/Users/John/Music/Music/turret.OGG'))
sounds.append(pygame.mixer.Sound('D:/Users/John/Music/Music/portalend.OGG'))
for sound in sounds:
sound.play()
Run Code Online (Sandbox Code Playgroud)