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

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



Thanks for the help everybody, but it still doesn't work.

I've tried these functions as collided values (as Jeffrey Kleykamp
suggested):

pygame.sprite.collide_rect() takes only sprites as values and then uses
their rects. That means I can't use the sprite's scaled "hitbox" attribute,
otherwise I get this error: AttributeError: 'pygame.Rect' object has no
attribute 'rect'  
And if I do sprite.rect = sprite.hitbox, the image gets blitted at the top
left corner again.

pygame.Rect.colliderect() doesn't work.

pygame.sprite.collide_rect_ratio() works as intended but causes a huge
performance drop, so it's not useable for me. I have quite a lot of sprites
on the screen (sometimes over 100).

Christopher Night is right. It would be a lot easier for me, if Pygame
sprites had an additional (optional) hitbox rect.

Maybe I should rewrite my collision detection passage and just use
pygame.Rect.colliderect() instead of pygame.sprite.spritecollide(). 



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