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.
如何创建一个小于图像的矩形?据我所知,在图像周围创建矩形的唯一方法是使用:
self.rect = self.image.get_rect()
但这会创建一个比图像更大的矩形。谢谢。
Pygame 中的“矩形”是一个简单的对象,用于在函数和方法之间传递表面上的坐标。有一个pygame.rect.Rect类,您将 (x, y, width, height) 传递给该类进行实例化。除了那个特定的类之外,pygame 中几乎所有需要矩形的函数也将接受一个普通的 (x,y, width, height) 元组——包括碰撞验证。
pygame.rect.Rect