【发布时间】:2019-01-07 08:07:39
【问题描述】:
按钮单击功能不会运行,除非我单击左上角的退出按钮,这不会关闭我的游戏,而是执行我实际要求它执行的任务。帮助?
def game_intro():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
elif event.type == pygame.MOUSEMOTION:
for button in buttons:
if button[1].collidepoint(event.pos):
button[2] = HOVER_COLOR
else:
button[2] = BLACK
screen.blit(bg, (0, 0))
for text, rect, color in buttons:
pygame.draw.rect(screen, color, rect)
screen.blit(text, rect)
pygame.display.flip()
def button_clicked():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
if event.type == pygame.MOUSEBUTTONDOWN:
print('test')
pygame.display.flip()
clock.tick(60)
game_intro()
button_clicked
pygame.quit()
【问题讨论】:
标签: python loops button pygame main