Python 在画布上检查鼠标位置时出错(Pygame)
我的代码应该检查我的鼠标位置,然后打印出来,但它只检查一次,有什么问题Python 在画布上检查鼠标位置时出错(Pygame),python,tuples,pygame,Python,Tuples,Pygame,我的代码应该检查我的鼠标位置,然后打印出来,但它只检查一次,有什么问题 import pygame, sys, time from pygame.locals import * pygame.init() WINDOW_WIDTH = 1000 WINDOW_HEIGHT = 600 surface = pygame.display.set_mode ((WINDOW_WIDTH, WINDOW_HEIGHT),0,32) pygame.display.set_caption ('get P
import pygame, sys, time
from pygame.locals import *
pygame.init()
WINDOW_WIDTH = 1000
WINDOW_HEIGHT = 600
surface = pygame.display.set_mode ((WINDOW_WIDTH, WINDOW_HEIGHT),0,32)
pygame.display.set_caption ('get POS')
while True:
amntTuple = pygame.mouse.get_pos()
print (amntTuple)
time.sleep(0.2)
您需要建立并设置适当的pygame事件处理循环。您需要建立并设置适当的pygame事件处理循环。调用以从pygame事件队列获取新事件
while True:
for event in pygame.event.get():
amntTuple = pygame.mouse.get_pos()
print (amntTuple)
调用以从pygame事件队列获取新事件
while True:
for event in pygame.event.get():
amntTuple = pygame.mouse.get_pos()
print (amntTuple)