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


when click one time

number will appear top here


thank you for reading my blog










































ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

How to Export Window Desktop game in godot

How to create animation in krita frame by frame for game

How to create button and click exit game in Godot