我是python和pygame的新手,我很难理解这个错误信息

时间:2013-05-27 22:46:13

标签: pygame

import pygame, sys
from pygame.locals import *

pygame.init()

window = pygame.display.set_mode((640,360),0,32)
pygame.display.set_caption("My game.")

black = [0,0,0]
white = [255,255,255]

img = pygame.image.load("images/bg.jpg").convert_aplpha() # This is where I get the error.

我得到的错误是img = pygame.image.load("images/bg.jpg").convert_aplpha() AttributeError: 'pygame.Surface' object has no attribute 'convert_aplpha' 请问,这是什么意思,我该如何解决?

1 个答案:

答案 0 :(得分:1)

convert_aplpha()根本不是函数或属性。也许你的意思是convert_alpha()

# wrong
img = pygame.image.load("images/bg.jpg").convert_aplpha()
# right
img = pygame.image.load("images/bg.jpg").convert_alpha()