'Is there any way to delete a button after I press it
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)
Solution 1:[1]
Yes, destroy(b_render)
will remove the entity completely. If you plan to reuse the button later, I recommend setting .enabled
to False
instead.
Solution 2:[2]
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)
Solution 3:[3]
You can destroy the button with the destroy() function:
def b_logic():
print("button pressed")
destroy(b_render)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | pokepetter |
Solution 2 | Tanay |
Solution 3 | Chateauvisionn |