The end goal for each level will be a flag.
The end goal for each level will be a flag.
Reaching this flag will trigger a change in the game.
Reaching this flag will trigger a change in the game.
Such as loading a new level.
Such as loading a new level.
Create a new Scene.
Create a new Scene.
Add an Area2D node
Add an Area2D node
Call it EndFlag
Call it EndFlag
Add A Sprite as a childe
Add A Sprite as a childe
Use tile_0112.png as the Texture
Use tile_0112.png as the Texture
Add a CollisionShape 2D
Add a CollisionShape 2D
Add a Rectangle Shape
Add a Rectangle Shape
Enclose the Flag
Enclose the Flag
Save the Scene as EndFlag
Save the Scene as EndFlag
Scripting the flag
Scripting the flag
Select the EndFlag Node
Select the EndFlag Node
Add a Script and call it endflag.gd
Add a Script and call it endflag.gd
Add the body_entered signal and connect it.
Add the body_entered signal and connect it.
Now add a variable to store the next scene file.
Now add a variable to store the next scene file.
Now implement the body_entered function
Now implement the body_entered function
Notice that in 2D Scene view in the inspector
Notice that in 2D Scene view in the inspector
Next Scene is currently <null>
Next Scene is currently <null>
To test the functionality.
To test the functionality.
Drag in our Level1.tscn file.
Drag in our Level1.tscn file.
Add a flag to the level.
Add a flag to the level.
When you touch it
When you touch it
Level 1 will reload.
Level 1 will reload.
Now you can create multiple levels using the TileMap and dragging and dropping components into your new Level Scene
Now you can create multiple levels using the TileMap and dragging and dropping components into your new Level Scene