Pygame帮助; mouse.get_pos()

时间:2014-03-13 02:26:20

标签: python pygame

我在pygame中测试了一些东西。为什么这会不断更新光标的位置

while 1:
    pos = pygame.mouse.get_pos()
    screen.fill(black)
    screen.blit(ball,pos)
    pygame.display.flip()
    print pos
    if pygame.event.get(27):
        a = "exit"

虽然这不是吗?

while 1:
    pos = pygame.mouse.get_pos()
    screen.fill(black)
    screen.blit(ball,pos)
    pygame.display.flip()
    print pos
    if pygame.event.get():
        a = "exit"

1 个答案:

答案 0 :(得分:2)

这与您编写pygame.event.get()

的方式有关
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            a = "exit"
    pos = pygame.mouse.get_pos()
    screen.fill(black)
    screen.blit(ball,pos)
    pygame.display.flip()
    print(pos)
    #here you should also include a pygame.time.Clock().tick(60) to set the FPS