Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Sheggif |
I made a “parent scene” that I make inherited scenes from. Its a button with a picture and text with a color rect. I made code were it has a variable made into a string called scene_to_load and a variable that lockes and unlocks the level called unlocked. I made it so that if its lock(unlocked = false) then darken it with a color rect. It recieves a signal when the button is pressed and if its unlocked(unlocked = false) then it gets_tree whaterver that function is (if you can teach me about it then pls) and changes the scene into the scene_to_load variable/string. Here is the code if you need to see:
extends Button
export(String) var scene_to_load
export var unlocked = false
func _physics_process(delta):
if !unlocked:
$ColorRect.color = Color(0,0,0,0.2)
func _on_Button_pressed():
if unlocked:
get_tree().change_scene(scene_to_load)