In this part, I will guide you to create a button to select a level like in the Map level there are some level 1,2,3 cells and then choose to play.
Select Level
Scene
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 clicked.
The 3 Texture Rects are used to display the star.
You copy the circle on the side of the UI folder in the Level map to the TextureButton
Then the Texture Rect then 3 drag the star in.
Then adjust the stars in order from left to right.
Then I renamed it again.
Add a Label named SoLevel to display Level.
I used Customs Font in the previous section.
Then save the scenes again.
Then add it the Script.
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.
Here I will use export to export 3 variables to Inspector
And Sodiem here I will follow the 100 scale. SoDiem here will be calculated 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, but if you use load(), it will load the image when you touch it.
Then Instance the newly created Level into the LevelMap.
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.
MapName with the original node name.
And after running the game, I will have the results as above.
After clicking on it, I will be transferred to Level 1.
summary
In the next section, I will show you how to create a stop menu and when you win a level.