这几行Python 3.2代码使用最新的pygame模块来移动图像。它与此示例相关:http://www.pygame.org/docs/tut/MoveIt.html
以下是我的代码:
import pygame
import sys
pygame.init()
screen = pygame.display.set_mode((600,400))
bg = pygame.image.load('bg.jpg')
player = pygame.image.load('player.jpg')
pos = player.get_rect()
while True:
for i in pygame.event.get():
if i.type() == pygame.QUIT:
sys.exit()
screen.blit(bg,(0,0))
screen.blit(player,(i,i))
pygame.display.update()
运行时出现以下错误:
Traceback (most recent call last):
File "C:/Users/Grounds Keeper Willy/Desktop/Python Code/test.py", line 12, in
if i.type() == pygame.QUIT:
TypeError: 'int' object is not callable
我发现有类似的问题,但答案指出问题是将函数名用作变量,而这不是我的情况。我似乎无法弄清楚问题出在哪里。