0

当我在基于 pygame 的游戏中使用精灵时,它们似乎无法正常工作 - 正如您在屏幕截图中看到的那样,它们的形状不正确并且上部有一些奇怪的变形。

黑色方块顶部有扭曲;中心的精灵必须是箭头形状的。

加载图像所涉及的一段代码(从 pygame 的教程中复制粘贴):

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()

我一直在 Mac OS X 上的 Python 2.7.11 和 3.4.2 上做我的项目并遇到了这个问题。但是当我在 Windows 上的 Python 3.1 上测试它时,问题没有出现并且精灵加载正常。所以我认为这与 Mac OS X 有关。

4

1 回答 1

1

你在 El Capitan (OS X 10.11) 上吗?如果是这样,您会在该版本的 OS X 上看到 SDL_image 中的一个已知错误。有关详细信息和可能的解决方法,请参阅此链接:

https://bitbucket.org/pygame/pygame/issues/284/max-osx-el-capitan-using-the-deprecated

于 2015-12-14T19:44:16.387 回答