Oops, my code was wrong, it should be, my_collide_rect = lambda a, b: a.hitbox.colliderect(b.hitbox)
You want to use the colliderect function of the Rect module to test if they collide. http://www.pygame.org/docs/ref/rect.html#pygame.Rect.colliderect Jeffrey On Fri, May 23, 2014 at 10:02 AM, Skorpio <skorpio2...@yahoo.de> wrote: > 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. > -- Jeffrey Kleykamp