Gabriel Hasbun wrote:
Hello, The piman's tutorial on sprites: http://kai.vm.bytemark.co.uk/~piman/writing/sprite-tutorial.shtml class MySprite(pygame.sprite.Sprite): image = None def __init__(self): pygame.sprite.Sprite.__init__(self) if MySprite.image is None: # This is the first time this class has been instantiated. # So, load the image for this and all subsequence instances. MySprite.image = pygame.image.load("image.png") self.image = MySprite.image
The assignment is unnecessary. MySprite.image is already visible as self.image.
Refers to MySprite.image , as variable common to all instances, I guess, somewhat a static member in C++, Am I right?This is more of a python question, I went through the docs but found nothing related.Thanks in advance.
-- Lenard Lindstrom <len-l@xxxxxxxxx>