• 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 get 60 days of free web hosting without a card
Tips

How to get 60 days of free web hosting without a card

November 25, 2026
How to cancel Facebook Plus package to avoid automatic renewal
Tips

How to cancel Facebook Plus package to avoid automatic renewal

November 23, 2026
How to unlock iPhone Duo face on iOS 27.3 Beta 2
Tips

How to unlock iPhone Duo face on iOS 27.3 Beta 2

November 23, 2026
Naykia: App saves posts across multiple platforms, keeping the post intact even if the original post is deleted
Tips

Naykia: App saves posts across multiple platforms, keeping the post intact even if the original post is deleted

November 22, 2026
Free CNSF certification exam guide from Red Team Leaders
Tips

Free CNSF certification exam guide from Red Team Leaders

November 21, 2026
Instructions for registering Google AI Pro for 2 years for free until 2028
Tips

Instructions for registering Google AI Pro for 2 years for free until 2028

November 21, 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

Try the extremely funny game to cure lisp

Try the extremely funny game to cure lisp

November 30, 2026
Who is Xiaomi 18 Pro for? Who shouldn’t buy?

Who is Xiaomi 18 Pro for? Who shouldn’t buy?

November 30, 2026
Immediately install the Add-in that standardizes text format for Word

Immediately install the Add-in that standardizes text format for Word

November 29, 2026
AnonyViet LLM – Summary of 125 Prompt Jailbreak AI, Uncensored

AnonyViet LLM – Summary of 125 Prompt Jailbreak AI, Uncensored

November 29, 2026
Try the extremely funny game to cure lisp

Try the extremely funny game to cure lisp

November 30, 2026
Who is Xiaomi 18 Pro for? Who shouldn’t buy?

Who is Xiaomi 18 Pro for? Who shouldn’t buy?

November 30, 2026
Immediately install the Add-in that standardizes text format for Word

Immediately install the Add-in that standardizes text format for Word

November 29, 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

Try the extremely funny game to cure lisp

Try the extremely funny game to cure lisp

November 30, 2026
Who is Xiaomi 18 Pro for? Who shouldn’t buy?

Who is Xiaomi 18 Pro for? Who shouldn’t buy?

November 30, 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