How can I update the text position when I change the button position?

1

I have a class button that is a sprite and has a text attribute that is also a sprite. I wanted to know how to change the position of the text when I change the position of the button rect?

import pygame


class Botao(pygame.sprite.Sprite):
    def __init__(self, text):
        self.image = pygame.image.load("images/botao.png")
        self.rect = self.image.get_rect()
        self.text = Text(font["alfa_slab_one_40"], text, "#ffffff")


class Text(pygame.sprite.Sprite):
    def __init__(self, font, text, cor, fundo=None):
        self.image = font.render(text, True, cor, fundo)
        self.rect = self,image.get_rect()


botao = Botao("SIM")
botao.rect.center = self.tela_rect.center
    
asked by anonymous 12.11.2017 / 13:02

0 answers