[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Virtual attributes of pygame.Rect



If the self argument ( sean's post ) doesn't fix the problem, it could
be that the Rect() is actually a tuple. I ran into this before.

To fix this, see:
http://www.mail-archive.com/pygame-users@xxxxxxxx/msg05338.html

On Dec 26, 2007 4:04 AM, <p22sacam@xxxxxx> wrote:
>
>
>
> Hi everyone,
>
> First of all,merry Xmas!
>
> I would like to ask about the virtual attributes of pygame.Rect (I mean: top, left,centerx...and so on)
> I have 2 classes, board() and square(). At class Square I have some methods like:
>
> def setRect(x,y,w,z):
>     self.rect=pygame.Rect(x,y,w,z)
>
> def getXposition():
>   print "value top left: ", self.rect.left#this is only to check the value is  correct
>   return self.rect.left
>
> And then at Board() class I have instances of Square():
>
> newSquare= Square()
>
> After that I asign rects values with newSquare.setRect(x,y,w,z), but when I try to access to the "left" virtual attribute with newSquare.getXposition, it says me that the object doesn't have a left attribute when in getXposition I try to print the value.
>
> Does anyone know, more or less, what I'm doing wrong?
>
> Thanks for all!



-- 
Jake