我无法让一个非常简单的 pygame 脚本工作:
import pygame
class MainWindow(object):
def __init__(self):
pygame.init()
pygame.display.set_caption('Game')
pygame.mouse.set_visible(True)
# pygame.mouse.set_visible(False) # this doesn't work either!
screen = pygame.display.set_mode((640,480), 0, 32)
pygame.mixer.init()
while True:
print pygame.mouse.get_pos()
pygame.mixer.quit()
pygame.quit()
MainWindow()
当我在窗口周围移动鼠标时,这只会输出 (0,0):
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
任何人都可以检查这个吗?
编辑 - 固定代码:
import pygame
class MainWindow(object):
def __init__(self):
pygame.init()
pygame.display.set_caption('Game')
pygame.mouse.set_visible(True)
# pygame.mouse.set_visible(False) # this doesn't work either!
screen = pygame.display.set_mode((640,480), 0, 32)
pygame.mixer.init()
while True:
for event in pygame.event.get():
if event.type == pygame.MOUSEMOTION:
print pygame.mouse.get_pos()
pygame.mixer.quit()
pygame.quit()
MainWindow()