python - Pygame碰撞

标签 python collision-detection pygame sprite

如何使用pygame.sprite.collide_rect

我想做一个游戏,如果女孩在冰上,她会滑动,而当她在地面上时(这将是另一个 Sprite ),她不会幻灯片。我打算使用 pygame 的碰撞检测,但我不确定如何使用。

有人可以帮我吗?

非常感谢

最佳答案

你能发布你的代码吗?

据我所知,您想要的是这样的:

if pygame.girl.colliderect(ice.rect):
     girl.slide()
elif pygame.girl.colliderect(ground.rect):
     girl.notslide()

关于python - Pygame碰撞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8305908/

相关文章:

java - 如何让物体在另一个物体接触后消失?

unity-game-engine - Unity3d 与网格的碰撞

python - 为什么 event.type 函数返回名称错误?

python - “道奇”式游戏

python - 带有切片的 Q 网络损失的 Tensorflow 实现

python - 为什么 numpy 向量化函数显然被称为额外时间?

python - 简单游戏的碰撞检测/物理

python - 如何使用 Pygame 将设计分辨率缩放到其他分辨率?

python - 如何从 python Dash 服务器进行串行通信

Python Pandas Dataframe 替换低于阈值的值