[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] piman's tutorial.Class variable usage.
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
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.
Never miss a thing. Make Yahoo your homepage.