我想做一个游戏。在我的游戏中有一个商店和战斗模式。当我使用collidepoint()
时,如果collidepoint()
是True
,那么它调用一个函数。但当我调用函数时,窗口会显示,不重新发送。我想不出这个问题,希望你能解决
def lvl1():
screen.blit(stickmanlvlim,(0,0))
pygame.display.update()
def lvl2():
screen.blit(stickmanlvlim,(0,0))
pygame.display.update()
def lvl3():
screen.blit(stickmanlvlim,(0,0))
pygame.display.update()
def fight(events):
lvl1R = pygame.Rect((20,335),(50,50))
lvl2R = pygame.Rect((170,335),(50,50))
lvl3R = pygame.Rect((320,335),(50,50))
world1setup()
fight = True
while fight:
for event in events:
if event.type == pygame.QUIT:
fight = False
if event.type == pygame.MOUSEBUTTONDOWN:
spot2 = pygame.mouse.get_pos()
if lvl1R.collidepoint(spot2):
lvl1()
if lvl2R.collidepoint(spot2):
lvl2()
if lvl3R.collidepoint(spot2):
lvl3()
问题出在fight()
函数中。没有错误
尝试在不同的函数中调用事件,例如:
不要忘记在while循环的开头添加
pygame.event.get()
相关问题 更多 >
编程相关推荐