这几行
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
我发现了类似的问题,但答案表明问题是使用函数名称作为变量,这不是我正在做的事情.我似乎无法弄清楚这里有什么问题.
Original: https://blog.csdn.net/weixin_39683858/article/details/111911670
Author: weixin_39683858
Title: python中int对象不可调用_python-3.x – Pygame TypeError:’int’对象不可调用
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/783791/
转载文章受原作者版权保护。转载请注明原作者出处!