在全局框架中,我将timetest设置为True,但是当我运行此函数时,则表示在分配之前已引用了timetest。
def hover(leftmost,rightmost,downmost,upmost,characterpicked):
if event.type == pygame.MOUSEMOTION:
if event.pos[0] > leftmost and event.pos[0] < rightmost:
if event.pos[1] > downmost and event.pos[1] < upmost:
#not complete
if timetest == True:
#original time touched name
timetestorg = pygame.time.get_ticks()
timetest = False
print(timetestorg)
print(pygame.time.get_ticks())
#checks a few seconds after
if (pygame.time.get_ticks() > timetestorg + 700 and pygame.time.get_ticks() < timetestorg + 800):
#check location still good
if event.pos[0] > leftmost and event.pos[0] < rightmost:
if event.pos[1] > downmost and event.pos[1] < upmost:
#create person object called ness
name = "player" + str(playernum)
playernum += 1
name = Person(characterpicked)
#put selected on screen
creation = True
chosen = myfont.render("Selected", 1, (0,0,0))
#make sure to check if you changed choseness to chosen
timetest = True
第39行,悬停 如果timetest == True: UnboundLocalError:分配前已引用本地变量“ timetest”