Image Download URL:
Support My Patreon:
In this first lesson, we shall talk about the basics of all basics, it doesn't matter if you are using GoDot to create applications or games; all of these consist of you being able change from one scene to another, like going from the start menu scene to the actual game play scene.
These is what we will be covering on the first lesson:
1: How to set the resolution of your game.
2: How to create scenes.
3: How to switch between them.
4: How to incorporate a button to make the switch happen when you press it.
Let's get straight to it !
1st, create a new folder to house this project and copy the two images you can download here, the link is down in the description.
2nd, Open GoDot, New Project, Browse, and browse to that New Folder you have created for this lesson, Click Open, Click Create, and then Double Click on the Project to load it up.
This is how you set the resolution of your game, go to Scene, Project Settings, Display, for this lesson, we shall set the Width and Height to 1024 and 576 respectively.
Let's create our first layout.
Very easy, first thing you do RELIGIOUSLY, is to add a base Node like so.
Change the name of the Node to Layout 1.
Now let's add a Sprite a.k.a graphic to this layout, add a Child Node by right clicking here and select Sprite like so.
Rename the Sprite to Background.
Under Texture, Select Load, Load Layout 1.png, now move the sprite to fit into the rectangular region outlined by very thin lines.
You can turn this on to better help you place your Sprite in place.
Time to incorporate a button, right click Layout 1, Add Child Node, Button, Size and Move the Button into place.
Set the Button Text to "Click Me".
Now save your Scene as "Layout 1".
Congratulation, you just finished your first layout.
Now let's create a second Scene, click scene, New Scene and repeat the whole thing again but with a different image.
Save this scene as "Layout 2".
Now it's time to add the scripts, right click on the base node, add script, name it "layout2.gd", click create.
Now select the button, select the node tab, double click pressed, select the base node, and hit connect.
Enter this one line of code here.
Now save the scene.
Do the same for Layout 1, name the script "layout1.gd" and repeat what we did previously.
Change the scene to switch to Layout 2 here.
Click the play button, GoDot will ask you to choose which layout to load first, select Layout 1, click play again and there you go !
Click the button to see that it works !
There, straight to the point, you've learned how to import graphics, getting buttons to work and even learned how to switch layouts.
Because of this first lesson, I will never have to talk about how to save Scene and how to add Child Nodes again, the videos in the future will be even more straight to the point because of this.
If you wish to see more straight to the point tutorials like these, vote with your wallet, contribute to my Patreon here.
Thank you !