GDevelop 5 beginner faq
#1 How can I deactivate keys or buttons?
We add a boolean-scene-variable and call it busy.
When we die, open a menu, etc. we can set the veribale to true.
If we add a condition to our control events now, the buttons are only executed if our variable is false.
#2 How can I save and load things?
In order to save high scores, unlocked levels, etc. locally, we need the storage actions.
The action "Write a value" saves the content of a variable.
After starting the game, we load the saved content into a scene-varibale.
If we need the value in several scenes, we write it from the scene-varibale to a global-varibale.
#3 How do I create a toggle button?
To create a toggle button or key, we need an additional boolean varibale.
So the second sub-event is not triggered if the first has been executed.
#4 How do I switch between scenes with buttons?
First we create a Sprite Object named sceneButtons and choose our button graphics as two animations.
Now we drag the button twice into our scene and change the Animation in the Properties Manager
to 1 for one of them.
We create a global variable with the name currentScene and the default value 1.
Then an mouse click event for our button and two sub-events with the object-variable
button, to check which button was pressed.
The action adds or subtracts a number for the scene name.
The second condition deactivates the button when we have reached the first or last scene.
Now we give our buttons variable the value left / right in the Properties Manager.
To change the scene, we add a third sub-event. We fill the scene-variable newScene with the name
we want to change to and use it in the Change the scene action.
With these two events we can hide one button when we are in the first or last scene.
External events
To avoid having to copy the code into each scene, we use an external event sheet.
We move the code from scene1 to the external sheet and add a link to it in scene1.
(Right Click » Add Other » Link)
External layout
We make our button available in every scene. (Right Click ยป Set as a global object)
Now we create an external layout, place our buttons in it and include this action in our
external events sheet at the beginning.
#5 How do I move an object from left to right?
We create a sprite object with the name directionChanger with the object-variable direction and add the
object twice to the scene.
Now we create a colision event with a toggle-boolean-scene-variable action and two events to
move our object.
#6 How do I detect the time during the game was closed?
Events are not executed when the game is not active, so we have to save and load the last time it was
open. Because users could close the game without using our exit button, we save the current time every
20 seconds.
When the game starts we check if a time has already been saved.
1. Read timeOld from the storage and and save it in the scene-variable timeOld.
2. Subtract timeOld from the current time and save it in timeOffline.
3. If we divide by 1000 and use round, we get the time that the app was closed in seconds.
4. We save the current time in storage.
#7 How do I notify desktop users about a game update?
We need a web space to save an availableVersion.txt with the latest version number.
Alternatively firebase Remote configuration or Firestore can be used.
After starting the game we define the current version number and load the latest one from our .txt
on the server.
We check if the available number is higher than the installed one and create a notification text and
download button. We don't use it as a sub-event because there is a little delay at loading from the server.
When the user clicks on the download button, the download is started or a download page is opened
in the browser.
#8 How do I create a cutscene??
First we deactivate the player input as explained in #1 when an event happens and our cutscene should
be started.
my gdevelop games
my gdevelop extensions
IFrame
Offers an action to create, configure
and delete IFrames inside the game.
Project properties
Allows to access Version number and
Author name from Project properties
with an expression.