【发布时间】:2020-07-25 09:14:13
【问题描述】:
def options():
options = True
while options:
for event in pygame.event.get():
win.fill(WHITE)
win.blit(background, (0, 0))
... # Blitting text and switch buttons
options_x, options_y = pygame.mouse.get_pos()
if event.type == pygame.QUIT:
# Exit button
pygame.QUIT()
quit()
elif event.type == pygame.MOUSEBUTTONDOWN:
# Sound effect tuning
if 470 > options_x > 390 and 220 > options_y > 185:
# Checking if mouse click is on the ON SWITCH
mouse_click.play()
screen.blit(off_switch, (off_switch_x, off_switch_y))
pygame.mixer.stop()
# But doesn't stop sound from playing when I quit options section
# Music effect tuning
elif 470 > options_x > 390 and 300 > options_y > 260:
# Checking if mouse click is on the ON SWITCH
mouse_click.play()
screen.blit(off_switch, (off_switch_x, off_switch_y))
pygame.mixer.music.stop()
# Interactive BACK button
elif 90 > options_x > 42 and 75 > options_y > 25:
mouse_click.play()
options = False
pygame.display.update()
所以这是我的 HANGMAN 游戏的一部分,我在其中尝试设置 OPTIONS 部分,以便您配置音量。
问题在于“音乐”和“声音”效果调整。
按下“音乐”和“声音”的 ON SWITCH 按钮将显示 OFF SWITCH,但只要我松开鼠标,它们就会恢复到原来的状态。
音乐停止,但音效停止(鼠标点击、扑通声等)。
我想保存图像块传输,并停止声音效果。 我该如何解决这个问题?
【问题讨论】:
标签: python-3.x pygame