有没有办法将精灵的矩形移动到中心?

问题描述 投票:0回答:0

enter image description here

class Personagem(pygame.sprite.Sprite):
      def __init__(self,x,y):
            super().__init__()
            self.imagem = pygame.image.load('sprites/frente-parado.bmp')
            self.rect = self.imagem.get_rect()
            self.rect.height = 10
            self.rect.width = 10
            self.rect.centerx = x
            self.rect.centery = y
            self.velocidade_x = 0
            self.velocidade_y = 0

使用此代码我可以控制矩形的大小,但我希望它位于精灵的死点

python pygame size collision rect
© www.soinside.com 2019 - 2024. All rights reserved.