How to update the position of the text when changing the position of the button?

Asked

Viewed 72 times

1

I have a boot class that is a Sprite and has as attribute text that is also a Sprite. I was wondering how to change the position of the text when I change the position of the boot rectum?

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
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.