0 votes

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 scenetoload 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 getstree whaterver that function is (if you can teach me about it then pls) and changes the scene into the sceneto_load variable/string. Here is the code if you need to see:

extends Button

export(String) var scenetoload
export var unlocked = false

func physicsprocess(delta):
if !unlocked:
$ColorRect.color = Color(0,0,0,0.2)

func onButtonpressed():
if unlocked:

in Engine by (20 points)

1 Answer

0 votes

I wasn't sure what your actual question was, so I'll just point out some things.

So first off, there's a page in the official documentation on the SceneTree which explains it better than I ever could.

Second, there's no need to set the color of the ColorRect every frame. You can just have it set to the locked color as default, and then change it when it's unlocked. Also, buttons have a disabledproperty which you could use instead of a ColorRect. You can access the button's pressed method directly with _pressed.

by (8,155 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.