[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] piman's tutorial.Class variable usage.
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] piman's tutorial.Class variable usage.
- From: "René Dudfield" <renesd@xxxxxxxxx>
- Date: Wed, 12 Dec 2007 12:19:31 +1100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 11 Dec 2007 20:19:40 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=1ah0LvrHBirFMh5vgZ0lYWqRgcT9Kz8ICpHENJNU8xI=; b=edZdDQPVlanuh0MqQsUFkLEAIeHpUZbd53ainJ6bZ6wtuQBubxkFhzRyGEek3OntdNR0ayf33IlhwymNksm+9SKuqvk2nj+pXigzLmt9dk4qvHnO05eonJcnyqA0TwU4VFUwunXG34REMhFzM0uZLqXSU6/e4vqGD6f1uiz9C9Y=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=JbAW7UC21o8UqAaB+ynsZYIui36BipoqUm20B099t+tm+qukwBVqYql7oBDwZVk0UJkSnPBZxhKcBaAkpRCg7b1BjPBcTyhOxfiWzrDerG8QcbrjV1nRnwNaaedVlKKDRvmJ3xXD3IkqdhyCyn6eyl02nQYsM1K26HzpAvPD3r8=
- In-reply-to: <604989.47177.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- References: <604989.47177.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
yeah, similar to static variables.
They are shared between all instances of that class.
On Dec 12, 2007 12:00 PM, Gabriel Hasbun <gastomaster@xxxxxxxxx> 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
> 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.
>
>