我对 pygame 很陌生,正在尝试制作一个游戏,其中 Actor 尝试击中 gem ,但我不知道如何使用“actor.collidepoint(pos)”函数!非常感谢您的回答!
最佳答案
参见Actor :
Actors have all the same attributes and methods as
Rect
, including methods like .colliderect() which can be used to test whether two actors have collided.
假设您必须 Actor
对象:
player = Actor("player_image.png")
gem = Actor("gem_image.png")
使用colliderect
方法来检测actor之间的碰撞:
if player.colliderect(gem):
print("hit")
有关 Pygame 中碰撞的更多信息,请参阅问题的答案:
关于python - 如何使用 "actor.collidepoint(pos)"检查 pygame 中 Actor 之间的碰撞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65222519/