【发布时间】:2014-04-29 13:26:06
【问题描述】:
我有一小段代码,如果满足 if 语句,就会播放一次声音:
for block in block_list:
if block.rect.y >= 650 and health >=25 and score < 70:
player_list.remove(player)
all_sprites_list.remove(player)
font = pygame.font.Font("freesansbold.ttf", 30)
label = font.render("SCORE TARGET NOT MET", 1, YELLOW)
labelRect = label.get_rect()
labelRect.center = (400, 250)
error.play()
laser.stop()
但是在播放“错误”声音时,它会继续循环,直到 pygame 窗口关闭。有什么办法可以编辑我的代码,让“错误”音效只播放一次?
谢谢。
【问题讨论】: