Hello everybody!
I used the code from here to create a button at runtime and attach a function to it:
https://docs.godotengine.org/en/stable/classes/class_button.html
func ready():
var button = Button.new()
button.text = "Click me"
button.pressed.connect(self.buttonpressed)
addchild(button)
func buttonpressed():
But when I run my program, it gives me the following error message:
Invalid get index 'buttonpressed' (on base: 'Node2D (palya1kodja.gd)'). Did you mean '.buttonpressed()' or funcref(obj, "buttonpressed") ?
If I try so: button.pressed.connect(self.buttonpressed())
I also get an error message: Invalid call. Nonexistent function 'connect' in base 'bool'.
What is wrong with this? Maybe button creating is not working in Godot 3.3 in this mode, only in Godot 4.0?