You have to call pygame.Surface.__init__ with your surface object first
("self"),
then pass further arguments like size:
class ExtendedSurface(pygame.Surface):
def __init__(self, string):
pygame.Surface.__init__(self, (100, 100))
self.fill((220,22,22))
# ...
ERName wrote:
Is it possible to extend the surface class? Every time I do the
surface ends up dieing somehow right after it is created... I may just
be doing it in the wrong way, though. The main point is to override
the __str__() method, so if you know another way besides extending
pygame.Surface, I'd be happy to hear it.
class ExtendedSurface(pygame.Surface):
def __init__(self, surface, string):
pygame.Surface.__init__(surface, surface.get_size()) #The docs
say to include a size, etc. but that just gives me "too many values to
unpack" errors.
self.string = string
def __str__(self):
return self.string
Thanks!