Because pygame
does not have a library-like function SFML - > View , I'm developing a "camera" format to scroll the screen and preserve the positions of the objects within the general coordinate within the "world".
As default for pygame
, use rectangle .
For ease of manipulation, I want to change the left
and%% variables obtained in get_rect , adding the camera offset to these variables.
Following this example of @jsbueno, I'm having a hard time:
I have a class top
and within it I get the rectangle of an image and store class Sprite(pygame.sprite.Sprite)
. Hence, I want to return a value other than self.ret = self.imagem.get_rect()
every time this variable is accessed.
But by declaring self.ret.left
and just below @property
I get def ret.left(self):
. What would be the correct sitaxe in this case?
import pygame
class Sprite(pygame.sprite.Sprite):
def __init__(self, imagem, x, y):
self.imagem = pygame.image.load('imagem.png')
self.ret = self.imagem.get_rect()
@property
def ret.left(self): # aqui aparece o erro