How to click button count up in Godot
Hi everyone to day i wll going show how to click button count number up in Godot.
open your project first.
right click Node2D then choose Add Child Node
type button in search bar then choose button
resize button what you want
right click Node2D again choose Attach Script.
click create
click Node button one time
click node then choose pressed() function
click create
create variable for count number and wil show in screen when press button
function _on_button_pressed():
count += 1
then will plus variable count +1 when press button
then click right Node2D again choose Add Child Node
type label in search bar when choose Label
go to 2D scene
change position and resize.
i will located it center.
then back to script
type $Label.text = str(count) this function
it's finished you can press f5 to run
ความคิดเห็น
แสดงความคิดเห็น