Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在抛弃 python 桌面,和我的朋友一起编写僵尸游戏。我看了又看,但不明白。有人能解释一下如何使用预先存在的图像并使其成为精灵,然后检查精灵碰撞吗?顺便说一句,它是自上而下的。
这适用于 python 2.7 和 pygame 1.8.1。
好的,所以 pygamesprite对象是一个 Bass 类,可用于创建其他类,然后您可以使用这些类来执行诸如碰撞检测之类的操作:
sprite
class Player(pygame.Sprite): def __init__(self): self.image = pygame.image.load("player.png").convert_alpha() self.rect = self.image.get_rect() self.pos = self.rect.x, self.rect.y #etc.......