1

So I was making a game in the Ursina engine and I made two of the same button:

class MainMenuButton(Button):
    def __init__(self, pos, text):
        super().__init__(
            model = 'cube',
            color = color.white,
            position = pos,
            rotation = (0, 90, 0),
            scale = (7, 1, 1),
            parent = scene,
            text = text,
            text_color = color.black,
            text_origin = (0, 0, -0.6)
            )

MainMenuButton = MainMenuButton((4.9, 4, 0), 'a')
MainMenuButton2 = MainMenuButton((4.9, 3, 0), 'b')

app.run()

When I launch the code without the last line, it works just fine. But when I pasted it back, it somehow doesn't work...? Any help?

  • 1
    Please include the error message in your question. I guess it is not the *last line* `app.run()` that is causing your problem but `MainMenuButton((4.9, 3, 0), 'b')`. – Michael Szczesny Dec 17 '21 at 17:41

1 Answers1

3

After you did MainMenuButton = MainMenuButton((4.9, 4, 0), 'a') MainMenuButton is a reference to object, not class name. You have a name conflict in your code. You need to rename the variable or the MainMenuButton class.

Ratery
  • 2,863
  • 1
  • 5
  • 26