The main scene is the current screen, or room, where the user is playing. It usually contains all the elements of your game within it, including the player character, the user interface (UI), etc. Actually, each scene, or screen of your game, acts as a self-contained game, and when the player moves from one room to another in your game, Godot simply unloads the current scene, and loads a new one. Of course some global state needs to be maintained to link them and make a game, but this state is as minimal as possible. See the Global state and saving chapter in the What you need to know as a game designer section for details. For now we will focus on the main scene, or if you prefer, how to create a room of your game. The structure will be the same in every main scene of your game.
The basic structure required by the main scene to function is as follows:
Here is an example with the first main scene of our mini-game, without terrain or character player:
And here is a more complex example of a main scene with a terrain and a player:
Basically, if the player succeeds in solving this main scene puzzle, the last action he does will tell Godot to go to the next main scene. We do that by scripting, usually on the last item used, something like a door. In Esc script, you write:
change_scene "res://scenes/game/next_scene.tscn"
Sometimes we need to play global effects, that must exist outside the current scene, or might "survive" the lifetime of the current scene. In this case we use an item that exists globally, with the global id telon (the Spanish word for "curtain"). This object contains animations for global effects such as fade_in, fade_out, etc. Since it's an item, it can be controlled by a script. The scene is in globals/telon.scn, and is instanced from the main.scn scene. So to have a smooth transition between two main scenes, you can write in your script:
cut_scene telon fade_out
change_scene "res://scenes/game/next_scene.tscn"
cut_scene telon fade_in
Additionally you will probably have to place you character at its entry point in the next scene with the teleport
function before the next scene appears:
cut_scene telon fade_out
change_scene "res://scenes/game/next_scene.tscn"
teleport main_player entry_point_position_item
cut_scene telon fade_in
Until now, Escoria has no specific feature to play a video or an animation between two main scenes, so the workaround is to create another main scene to put between the two, with a VideoPlayer
node playing an OGV file, and a script triggering the change to the next scene automatically at the end of the video or at click.
Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.
Vous devriez rafraîchir la page.