经过多次研究后,我找不到答案。
运行mac osx 10.8.4 python 2.7.5和pygame 1.9.2。
所有模块都在pygame的构建中找到,重新安装并不能解决问题 跑步时:
import pygame
import math
import random
black = (0,0,0)
red = (255,0,0)
white = (255,255,255)
blue = (0,0,255)
green = (0,255,0)
pygame.init()
print pygame.image.get_extended()
size = (1000,700)
screen = pygame.display .set_mode(size)
pygame.display.set_caption("My game")
done = False
clock = pygame.time.Clock()
background_image = pygame.image.load("red_x.png").convert()
while done == False:
# ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
# ALL EVENT PROCESSING SHOULD GO ABOVE THIS COMMENT
# ALL GAME LOGIC SHOULD GO BELOW THIS COMMENT
# ALL GAME LOGIC SHOULD GO ABOVE THIS COMMENT
# ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT
screen.fill(black)
screen.blit(background_image,[0,0])
# ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT
pygame.display.flip()
clock.tick(20)
pygame.quit()
我得到的文件不是有效的Windows BMP错误。
pygame.images.get_extended()
返回0
和
try:
import SDL_image
print "Loaded SDL_image"
except:
print "Failed to import SDL_image"
try:
import libpng
print "Loaded libpng"
except:
print "Failed to import libpng"
返回失败的导入消息。我认为这是我在搜索时看到的所有测试,他们所有的解决方案都没有用。
答案 0 :(得分:1)
我遇到了同样的问题,但我设法解决了安装以下版本的Pygame:http://pygame.org/ftp/pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg