【发布时间】:2018-07-30 01:12:38
【问题描述】:
函数 start_menu() 在按下按钮后会导致 run_instructions()。在 run_instructions() 中,一旦用户再次单击鼠标,它应该转到另一个函数,但是我认为前一个函数的单击会继续并自动触发 click[0] 到 = 1,尽管事实上没有人单击任何东西。
def run_instructions():
clicked = False
while clicked == False:
click = pygame.mouse.get_pressed()
board.blit(instructions,[0,0])
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if click[0] == 1:
create_environment()
clicked = True
def start_menu():
global menu
while menu == True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if 125 + 172 > mouse[0] > 150 and 448 + 69 > mouse[1] > 448 and click[0] == 1:
menu = False
run_instructions()
break
在进入run_instructions()时,是否有办法让click[0]更新或重置为0。我试过使用 pygame.MOUSEBUTTONDOWN 但它给出了同样的问题。
谢谢。
【问题讨论】:
标签: python python-3.x pygame python-3.5