[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Scaling the hitbox/rect of a sprite



You don't need to do that. rect.inflate already preserves the center. The question is more about how to use a separate rect for hitbox than you do for blitting.


On Thu, May 22, 2014 at 12:30 PM, Jake b <ninmonkeys@xxxxxxxxx> wrote:
To preserve the center:


ÂÂÂ pos = self.rect.center
ÂÂÂ self.rect = self.rect.inflate(-85, -20)
ÂÂÂ self.rect.center = pos





On Thu, May 22, 2014 at 5:47 AM, Skorpio <skorpio2011@xxxxxxxx> wrote:
Hi everybody,

How can you scale the hitbox of a sprite? I tried self.rect =
self.rect.inflate(-85, -20) and that scaled the rect correctly (to the
center of the rect), but the game still takes the upper left corner of the
rect as the blit position for the image/surface. That means the rect covers
only the upper left part of the sprite, so that the left half of the sprite
image can be hit and the right half can't be hit.

Regards,
Skorpio



--
View this message in context: http://pygame-users.25799.x6.nabble.com/pygame-Scaling-the-hitbox-rect-of-a-sprite-tp1227.html
Sent from the pygame-users mailing list archive at Nabble.com.



--
Jake