• 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

New features of Windows 10 21H1 are coming soon
Tips

New features of Windows 10 21H1 are coming soon

March 16, 2026
How to convert normal music into 8D music with Audioalter
Tips

How to convert normal music into 8D music with Audioalter

March 14, 2026
How to prevent your family’s Security Camera from being hacked
Tips

How to prevent your family’s Security Camera from being hacked

March 13, 2026
Pixel Agents: Turn VS Code into a Pixel Art Office for AI
Tips

Pixel Agents: Turn VS Code into a Pixel Art Office for AI

March 12, 2026
English learning app Memrise is offering a lifetime discount of only 21,000 VND
Tips

English learning app Memrise is offering a lifetime discount of only 21,000 VND

March 11, 2026
Instructions for upgrading to Windows 10 Sun Valley (February 21)
Tips

Instructions for upgrading to Windows 10 Sun Valley (February 21)

March 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
Inline Feedbacks
View all comments

Recent News

How to install extension to remind office workers to drink water

How to install extension to remind office workers to drink water

March 17, 2026
Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

March 16, 2026
New features of Windows 10 21H1 are coming soon

New features of Windows 10 21H1 are coming soon

March 16, 2026
Receive Advanced SystemCare 19 Pro key for free for 6 months

Receive Advanced SystemCare 19 Pro key for free for 6 months

March 16, 2026
How to install extension to remind office workers to drink water

How to install extension to remind office workers to drink water

March 17, 2026
Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

March 16, 2026
New features of Windows 10 21H1 are coming soon

New features of Windows 10 21H1 are coming soon

March 16, 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

How to install extension to remind office workers to drink water

How to install extension to remind office workers to drink water

March 17, 2026
Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

Why are iPhones and MacBooks still the number 1 “weapons” of the technology world?

March 16, 2026
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

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