• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[Tạo 2D Platformer Game với Godot] Part 18: Using the buttons

AnonyViet by AnonyViet
January 27, 2023
in Tips
0

In this part, I will show you how to use buttons like start and exit the game by connecting a signal and a few lines of code.

Join the channel Telegram of the AnonyViet 👉 Link 👈

Use

Add scripts

[Tạo 2D Platformer Game với Godot]  Part 18: Using the buttons

[Tạo 2D Platformer Game với Godot]  Part 18: Using the 14 . buttons

[Tạo 2D Platformer Game với Godot]  Part 18: Using the 15 . buttons

You add yourself a new script in the scene Menu.

Signal connection
[Tạo 2D Platformer Game với Godot]  Part 18: Using 16 . buttons

I will connect the signal of the NutBatDau node so that when I click it, it will move to scene level 1

[Tạo 2D Platformer Game với Godot]  Part 18: Using the 17 . buttons

Find and connect the pressed() signal. This signal will execute the command when the button is clicked by the user.

[Tạo 2D Platformer Game với Godot]  Part 18: Using 18 . buttons

Click connect
[Tạo 2D Platformer Game với Godot]  Part 18: Using the 19 . buttons

Connect successfully.

[Tạo 2D Platformer Game với Godot]  Part 18: Using the 20 . buttons [Tạo 2D Platformer Game với Godot]  Part 18: Using the 21 . buttons [Tạo 2D Platformer Game với Godot]  Part 18: Using 22 . buttons [Tạo 2D Platformer Game với Godot]  Part 18: Using the 23 . buttons

You will do the same for yourself for the game exit button.

Code

extends Control




func _on_NutBatDau_pressed():
    pass # Replace with function body.


func _on_NutThoatGame_pressed():
    pass # Replace with function body.

Here is the original code.

extends Control




func _on_NutBatDau_pressed():
    get_tree().change_scene("res://Scences/Map/Map.tscn")
    pass # Replace with function body.


func _on_NutThoatGame_pressed():
    get_tree().quit()
    pass # Replace with function body.

And here is the code that I added and it only adds 2 lines.

At the start button I will add the function change_sence() to change through the scene I want and change_scene() can only be called through get_tree().

At the game exit button, I use the quit() command, this command will automatically close your game

[Tạo 2D Platformer Game với Godot] Part 18: Using the buttons

Then you press F6 run the game and will see that when you press BAT DAU you will be moved to another scene and when you press THOAT GAME your game will be exited.

summary

This part is full of things that are quite easy to do.

In the next part, I will guide you how to design and redecorate the Menu interface so that it is beautiful and reasonable. It is expected that the Menu section will last for 2.3 more parts and then create a Game Stop Menu while playing the game.

The article achieved: 5/5 – (100 votes)

Tags: buttonsGameGodotPartPlatformertạovới
Previous Post

Top 10 Best Open World Games today

Next Post

3 White Hat Hacker Certifications you should have in 2021

AnonyViet

AnonyViet

Related Posts

How to create a virtual Pet, a virtual character running around on the Desktop to relax
Tips

How to create a virtual Pet, a virtual character running around on the Desktop to relax

October 15, 2026
15 cách tăng tốc Windows 10 nhanh như gió
Tips

15 cách tăng tốc Windows 10 nhanh như gió

October 14, 2026
How to create Guest mode Shortcuts for Chrome and Edge
Tips

How to create Guest mode Shortcuts for Chrome and Edge

October 13, 2026
Test what breed of dog you are through 10 multiple choice questions
Tips

Test what breed of dog you are through 10 multiple choice questions

October 13, 2026
Fliqlo – Create digital clock screens on Windows and phones
Tips

Fliqlo – Create digital clock screens on Windows and phones

October 12, 2026
SynthID Detector: Genuine AI checking tool from Google
Tips

SynthID Detector: Genuine AI checking tool from Google

October 11, 2026
Next Post
3 White Hat Hacker Certifications you should have in 2021

3 White Hat Hacker Certifications you should have in 2021

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted

Recent News

Instructions for receiving pension through VNeID without going to the ward

Instructions for receiving pension through VNeID without going to the ward

October 16, 2026
MBTI, Big Five, DISC or Holland: which personality test should you choose?

MBTI, Big Five, DISC or Holland: which personality test should you choose?

October 15, 2026
How to create a virtual Pet, a virtual character running around on the Desktop to relax

How to create a virtual Pet, a virtual character running around on the Desktop to relax

October 15, 2026
Record first, choose focus later: how to use 4K 60 fps Cinema mode on iPhone 18 Pro

Record first, choose focus later: how to use 4K 60 fps Cinema mode on iPhone 18 Pro

October 15, 2026
Instructions for receiving pension through VNeID without going to the ward

Instructions for receiving pension through VNeID without going to the ward

October 16, 2026
MBTI, Big Five, DISC or Holland: which personality test should you choose?

MBTI, Big Five, DISC or Holland: which personality test should you choose?

October 15, 2026
How to create a virtual Pet, a virtual character running around on the Desktop to relax

How to create a virtual Pet, a virtual character running around on the Desktop to relax

October 15, 2026
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Instructions for receiving pension through VNeID without going to the ward

Instructions for receiving pension through VNeID without going to the ward

October 16, 2026
MBTI, Big Five, DISC or Holland: which personality test should you choose?

MBTI, Big Five, DISC or Holland: which personality test should you choose?

October 15, 2026
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply