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、幅、高さ)があります。その特定のクラスを除いて、長方形を必要とするpygameのほとんどすべての関数は、衝突検証を含め、(x、y、幅、高さ)の通常のタプルも受け入れます。
pygame.rect.Rect