marienbad
marienbad

Reputation: 1453

pygame: resize a surface on which a subclass is based

I have a game class based on a pygame surface, and I initialise it like this:

game_obj(pygame.Surface)
    def __init__(self, x, y, width, height):
      super(game_obj, self).__init__((width, height)

Later in the game I want the object to change size, so I called super() again, but it doesn't appear to be the correct size, or when I fill it isn't filling properly. Is there something else I need to do?

Upvotes: 0

Views: 53

Answers (1)

furas
furas

Reputation: 142651

Using only super() again doesn't change it. Using super().__init__() could change it but I would rather create new instance of game_obj with new size and copy elements from old instance to new one, and delete old instance.

Or I would create object with two surfaces - smaller and bigger - and keep both.

Upvotes: 1

Related Questions