• 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 24 . 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

4 ways to fix bluetooth connectivity on Windows 11
Tips

4 ways to fix bluetooth connectivity on Windows 11

August 8, 2025
How to know the computer is tracked and processed by Keylogger
Tips

How to know the computer is tracked and processed by Keylogger

August 7, 2025
Opal: Create applications who do not need to write code
Tips

Opal: Create applications who do not need to write code

August 3, 2025
How to activate a new Start menu on Windows 11
Tips

How to activate a new Start menu on Windows 11

July 29, 2025
Intellgpt: AI tool for osint and data science
Tips

Intellgpt: AI tool for osint and data science

July 28, 2025
How to create Google Ai Pro 12 months free with Indian student account
Tips

How to create Google Ai Pro 12 months free with Indian student account

July 27, 2025
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 add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
How to install GPT-suns on who do not need the Internet

How to install GPT-suns on who do not need the Internet

August 12, 2025
How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
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 add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

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

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

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