Pygame碰撞
如何使用 pygame.sprite.collide_rect ?
我想做一个游戏,如果女孩在冰上,她会滑动
,而当她在地面上时(这将是另一个精灵
),她不会幻灯片。我打算使用 pygame 的碰撞检测,但我不知道如何使用。
有人可以帮我吗?
太感谢了
How do I use pygame.sprite.collide_rect
?
I want to make a game where if the girl is on ice she'll slide
and when she's on ground (which will be another sprite
) she won't slide
. I was going to use the collision detection from pygame, but I'm not sure how.
Can someone please help me?
Thank you so much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你能发布你的代码吗?
根据我的收集,你想要的是这样的:
Could you post your code?
From what I gather, what you want is something like this:
pygame 中有多种检测碰撞的方法。包括矩形、精灵组等...为了找到一种特定的碰撞检测方法,只需查看您正在使用的代码即可。但对于一个简单的精灵和矩形,你可以使用:
There are multiple ways to detect collision in pygame. Including rect, with groups of sprites, etc... In order to find one specific way of collision detection is just a matter of seeing the code you're working with. But with a simple sprite and rectangle you could just use: