Boton con codigo.
Boton con codigo:
---------------------------------------------------------------
extends Node2D
# Trabajando con Button
# Called when the node enters the scene tree for the first time.
func _ready():
var b = Button.new()
b.text = "Soy un botón!"
add_child(b)
---------------------------------------------------------------
Esto funciona en Godot4, aparece el botón, y cambia de estado al ponerse encima.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Ejercicio https://youtu.be/_-hpuSl4VvA?t=135
Crea un label y un boton
Label - Pulsa el boton para jugar
Buttton - Jugar
----------------------------------------
de https://docs.godotengine.org/en/stable/classes/class_button.html
Example of creating a button and assigning an action when pressed by code:
Esto si funciona en Godot4
extends Control
func _ready():
var button = Button.new()
button.text = "Click me"
button.pressed.connect(self._button_pressed)
add_child(button)
func _button_pressed():
print("Hello world!")
#Aparece el boton , lo pulsas y hace el print de Hello world

Comentarios
Publicar un comentario