Skip to content Skip to sidebar Skip to footer

Attributeerror: 'class' Object Has No Attribute 'rect'

I have this class: class Comet(pygame.sprite.Sprite): def ___init___(self): super().__init__() self.image = pygame.Surface((100,250)) self.image.fill(cometL) self.r

Solution 1:

Your definition for __init__ is wrong. You used three underscores (___init___), so this function is not called during instantiation of the class.

This means that the line self.rect = self.image.get_rect() isn't called and so there is no rect attribute.

Post a Comment for "Attributeerror: 'class' Object Has No Attribute 'rect'"