2015-12-14 42 views
0

當我在基於pygame的遊戲中使用精靈時,它們似乎無法正常工作 - 如截圖所示,它們沒有正確的形狀並且在上部具有一些奇怪的變形。Pygame庫 - 精靈無法在屏幕上正確呈現

Black squares have distortions on the top; sprite in the centre must be something like arrow-shaped.

一段代碼涉及加載圖像(從pygame中的教程右copypasted):

def load_image(name, colorkey=None): 
fullname = os.path.join('data', 'images') 
fullname = os.path.join(fullname, name) 
try: 
    image = pygame.image.load(fullname) 
except pygame.error as message: 
    print('Cannot load image:', fullname) 
    raise SystemExit(message) 
image = image.convert() 
if colorkey is not None: 
    if colorkey is -1: 
     colorkey = image.get_at((0,0)) 
    image.set_colorkey(colorkey, RLEACCEL) 
return image, image.get_rect() 

我一直在做我的項目上的Python 2.7.11和3.4.2在Mac OS X並得到了這個問題。但是當我在Windows上對Python 3.1進行測試時,問題沒有顯示,並且正常加載了精靈。所以我認爲這是關於Mac OS X的東西。

+0

可能使用不同的圖像格式,GIF,BMP,JPG,PNG – furas

+0

無,使用不同的格式將無濟於事。 – Verloren

回答