• 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 23: Choosing Level

AnonyViet by AnonyViet
January 26, 2023
in Tips
0

In this part, I will guide you to create a button to choose a level like in the Map level there are some level 1,2,3 cells and then choose to play.

Join the channel Telegram of the AnonyViet 👉 Link 👈

Select Level

Scene[Tạo 2D Platformer Game với Godot]  Part 23: Choosing Level

You create yourself a new scene with Control as the root node and 1 TextureButton and 3 Texturects.

TextureButton is what I use to create an image for the level and easily check if it is clicked.

The 3 Texture Rects are used to display the star.

[Tạo 2D Platformer Game với Godot]  Part 23: Choosing Level 22

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 23

You copy the circle in the UI folder in the Level map to the TextureButton
[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 24 [Tạo 2D Platformer Game với Godot]  Part 23: Choosing Level 25

Then the Texture Rect then 3 drag the star in.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 26

Then adjust the stars in order from left to right.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 27

Then I renamed it again.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 28

Add a Label named SoLevel to display Level.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 29 [Tạo 2D Platformer Game với Godot]  Part 23: Choosing Level 30

I used Customs Font in the previous section.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 31

Then save the scenes again.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 32

Then add it the Script.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 33 [Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 34

Then connect the signal pressed of HinhTron.

Script

extends Control

export (String) var MapName
export (String,FILE) var Scene
export (String) var Level
onready var ngoisaovang = preload("res://Assets/LevelMap/3 UI/Star1.png")
var SoDiem = 0

func _ready():
    $SoLevel.text = Level
func _process(delta):
    if SoDiem >= 1 and SoDiem <= 30:
        $NgoiSao1.texture = ngoisaovang
    elif SoDiem >= 30 and SoDiem <= 95:
        $NgoiSao1.texture = ngoisaovang
        $NgoiSao2.texture = ngoisaovang
    elif SoDiem >= 95:
        $NgoiSao1.texture = ngoisaovang
        $NgoiSao2.texture = ngoisaovang
        $NgoiSao3.texture = ngoisaovang


func _on_HinhTron_pressed():
    get_tree().change_scene(Scene)
    pass # Replace with function body.

As for the code, I will have the above.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 35

Here I will use export to export 3 variables to Inspector

And Sodiem here I will follow the 100 scale. SoDiem here will be derived from the number of stars that you collect when playing 1 level if all stars are enough, SoDiem is 100 and $NgoiSao1,2,3 will switch to yellow.

line has onready var I use it to load prior to The image of the yellow star means that when you run the game, it will always load, and if you use load(), it will load the image when you touch it.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 36

Then Instance the newly created Level into the LevelMap.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 37 [Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 38

You fill in the information.

MapName is the name of the root node of the underlying Scene.

Scene is you choose the scene of that level.

Level is used to display the level.

[Tạo 2D Platformer Game với Godot]  Part 23: Choose Level 39

MapName with the root node name.

[Tạo 2D Platformer Game với Godot]  Part 23: Choosing Level 40

And after running the game, I will have the same result as above.

After clicking on it, I will be transferred to Level 1.

summary

In the next part, I will show you how to create a stop menu and when you win a level.

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

Tags: ChoosingGameGodotLevelPartPlatformertạovới
Previous Post

How to see the exposed Password of Email or Username with PWNDB

Next Post

R MobileTrader: Multi-Platform Online Trading App

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
R MobileTrader: Multi-Platform Online Trading App

R MobileTrader: Multi-Platform Online Trading App

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