1

Is there any way that I can delete the b_render var when the b_logic function is activated? I have been trying different solutions for about an hour and nothing works. is there anything I overlooked?

from ursina import *

def b_logic():
    print("button pressed")

b_render = Button(scale = (.4,.1),color='red',text="start",on_click=b_logic)
ducklaster
  • 11
  • 2

3 Answers3

2

Yes, destroy(b_render) will remove the entity completely. If you plan to reuse the button later, I recommend setting .enabled to False instead.

pokepetter
  • 1,383
  • 5
  • 8
1

I stuck at this when I was making a snake game.

from ursina import *

def b_logic():
    destroy(b_render) # if you do not want to use it later.
    # or
    # b_render.enabled = False

b_render = Button(scale = (.4,.1),color='red',text="start",on_click=b_logic)
Tanay
  • 561
  • 1
  • 3
  • 16
1

You can destroy the button with the destroy() function:

def b_logic():
    print("button pressed")
    destroy(b_render)