The issue is not the pygame.sprite.Group.add
operation, but the obejct you want to add is not a pygame.sprite.Sprite
object, because the object is not constructed at all.
You missed to the super
call in the constructor of Projectile
. Furthermore the name of the constructor has to be __init__
rather _init_
:
class Projectile(pygame.sprite.Sprite):
#Initialize values
def __init__(self,x,y,direction):
super.__init__()
self.x = x
self.y = y
self.dir = direction
self.ttl = 30