I'm making a game in Pygame, and I have it so that if the character collides with a rect that it will push the character back a layer of pixels, creating a very small impassable boundary between it and the object. I was wondering that when I started to add art to it if I could have it covered up so it looked like a solid collision, or is there any way how a solid collision could function without their being that layer of pixels? Thanks in advance!
问问题
77 次
1 回答
2
当然,只需创建一个比usingRect
大一点Rect
的:Surface
inflate
返回一个大小由给定偏移量更改的新矩形。矩形仍然以其当前中心为中心。负值将缩小矩形。
s = your_surface # the Surface containing your image .
r = s.get_rect() # the rect of the Surface.
c_r = r.inflate(2, 2) # the rect used for collision detection.
于 2013-07-24T14:51:33.923 回答