如果我只做image.load('')。convert_alpha(),我可以得到我的所有图像。 当我尝试获得更多控制时,Surface只会杀死我,我不知道该怎么做。我需要帮助!!
import pygame, sys
pygame.init()
white = ((250,250,250))
black = ((0,0,0))
w = 800
h = 600
moveX = 0
moveY = 0
screen = pygame.display.set_mode((w,h))
pygame.display.set_caption('Paws')
background = pygame.image.load('C:/PythonImg/10121.jpg').convert()
clock = pygame.time.Clock()
Phil = pygame.image.load('C:/PythonImg/Phil_blob.png').convert_alpha()
Philpos = pygame.rect.Rect(0, 0, 400,300)
def Phil((Philpos), Phil):
screen.blit(Phil, (Philpos))
while pygame.display.get_init():
pygame.event.pump()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.display.get_init() == False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
moveX = -10
elif event.key == pygame.K_RIGHT:
moveX = 10
elif event.key == pygame.K_UP:
moveY = -10
elif event.key == pygame.K_DOWN:
moveY = 10
if event.type == pygame.KEYUP:
moveX = 0
moveY = 0
Philpos.move_ip(moveX, moveY)
Philpos.clamp_ip(screen.get_rect())
screen.fill(black)
screen.blit(background, (0,0))
Phil(Philpos, Phil)
pygame.display.update()
clock.tick(30)
pygame.QUIT()
quit()
听到我最新的错误
Traceback (most recent call last):
File "C:\Python27\Paws.py", line 57, in <module>
Phil(Philpos, Phil)
File "C:\Python27\Paws.py", line 28, in Phil
screen.blit(Phil, (Philpos))
TypeError: argument 1 must be pygame.Surface, not function
答案 0 :(得分:0)
将Surface存储在名为Phil的变量中,然后创建一个具有相同名称的函数。
不要这样做。给你的功能另一个名字或者删除它。