将图形编码到新的游戏基础上吗?

问题描述 投票:0回答:1

我是学习python和pygame的新手,在尝试在这里提问之前,我真的很努力。我很抱歉,而且每天都在进步。我最初的帖子@sloth告诉我如何从Sprite工作表中调用图形; Pygame: What is the best way to display these ships and their movement from sprite sheet?

从那时起,我一直在关注基于图块的游戏构建教程,该教程为我奠定了更好的基础。现在,我试图将显示给我的东西@sloth应用于新的Player类,以便可以显示在新环境中正确设置动画的飞船。接连不断出错,现在陷入困境。感谢所有帮助。真的,非常感谢。

这是我的代码。 https://github.com/riddoshi/game

python-3.x pygame 2d-games sprite-sheet pygame-surface
1个回答
0
投票

sprite构造函数中的图像加载代码不正确。

self.image = pg.image.load(SpaceShip, get_keys(self), (YELLOW_SHIP))

这看起来像某种粘贴错误。 可能想要成为类似这样的东西:

self.image = pg.image.load( SpaceShip )

但是我看不到SpaceShip的定义。它应该只是一个文件名字符串。

manual entrypygame.image.load()可能值得您阅读。它使用文件名(如上)或文件句柄作为参数。

© www.soinside.com 2019 - 2024. All rights reserved.