• 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 see your email account creation date
Tips

How to see your email account creation date

November 11, 2025
Microsoft’s ranking of the 10 best Windows versions
Tips

Microsoft’s ranking of the 10 best Windows versions

November 11, 2025
Recover deleted data on Windows 10 with Windows File Recovery
Tips

Recover deleted data on Windows 10 with Windows File Recovery

November 10, 2025
Tips

Why hasn’t your computer been updated to Windows 10 2004?

November 9, 2025
3 OCR Tools Extract Text from Images without Retyping
Tips

3 OCR Tools Extract Text from Images without Retyping

November 8, 2025
Ways hackers use to hack your Facebook and how to fix it
Tips

Ways hackers use to hack your Facebook and how to fix it

November 7, 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 install Anh Hai’s Pho Shop on MacBook is super easy

How to install Anh Hai’s Pho Shop on MacBook is super easy

November 11, 2025
How to turn off ads on Yoosee app in just 1 minute

How to turn off ads on Yoosee app in just 1 minute

November 11, 2025
Windows 11 and MS Office 2021 lifetime license, genuine from  during Keysoff’s 11.11 sale

Windows 11 and MS Office 2021 lifetime license, genuine from $14 during Keysoff’s 11.11 sale

November 11, 2025
How to see your email account creation date

How to see your email account creation date

November 11, 2025
How to install Anh Hai’s Pho Shop on MacBook is super easy

How to install Anh Hai’s Pho Shop on MacBook is super easy

November 11, 2025
How to turn off ads on Yoosee app in just 1 minute

How to turn off ads on Yoosee app in just 1 minute

November 11, 2025
Windows 11 and MS Office 2021 lifetime license, genuine from  during Keysoff’s 11.11 sale

Windows 11 and MS Office 2021 lifetime license, genuine from $14 during Keysoff’s 11.11 sale

November 11, 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 install Anh Hai’s Pho Shop on MacBook is super easy

How to install Anh Hai’s Pho Shop on MacBook is super easy

November 11, 2025
How to turn off ads on Yoosee app in just 1 minute

How to turn off ads on Yoosee app in just 1 minute

November 11, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

new88 trang chủ shbet trang chủ f168 trang chủ qq88 nhà cái 78win

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

new88 trang chủ shbet trang chủ f168 trang chủ qq88 nhà cái 78win

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