So basically I just wanted to create an enemy class with pygames.sprite.Sprite as the parent. But then I wanted to move this sprite object I created as well as add it to the screen. But it says blit is not a attribute of class “Enemy”. Sorry for the newb question but how do I go about doing this?
Class enemy:
class Enemy(pygame.sprite.Sprite):
#Class for falling enemys
def __init__(self):
# initialize the pygame sprite
pygame.sprite.Sprite.__init__(self)
# set image and rect
self.image = pygame.image.load("enemysprite.png").convert()
self.rect = self.image.get_rect()
What I’m calling to try to ad the sprite to screen
enemy = Enemy()
enemy.blit(100,100)
pygame.display.update()
Try this way :
you have to blit the sprite image in the pygame screen to display it.