[英]Pygame Help; mouse.get_pos()
I was testing things out in pygame. 我在pygame中测试了一些东西。 How come this constantly updates the position of my cursor 为什么这会不断更新我的光标位置
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 this doesn't? 虽然这不?
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"
it is to do with the way you have written pygame.event.get()
它与您编写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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.