Creating Point and Click Games with Escoria

Main Scene

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 scene structure

The basic structure required by the main scene to function is as follows:

  • A root node of type Node2D, with the script globals/ attached to it
  • A node named background, of type Control, with the script globals/ This is optional, it provides input handling for the background of your scene (i.e. clicking on the background to make the character walk to that position). It can be any type of Control node, including TextureFrame, etc. It is also used by default to calculate the total size of the scene, and to set the camera limits. When using a TextureFrame, remember to uncheck the "ignore mouse" property in Control if you want it to receive input [v2].
  • An optional Terrain node, which will define the walkable area for the character player, and will also allow to scale him according to perspective and light him according to a light map. We will explain in details how to create those maps in the Terrain: Light and Perspective chapter in the What you need to know as an artist section.
  • An optional player character.
  • Instances of all the items in your scene.
  • An instance of the "game" scene, found in globals/game.scn. This scene contains your UI, inventory, and basic game logic. You can use the Camera Limits property on the instance to override the size of the background. The game scene should be last in the children order of the main scene.

Here is an example with the first main scene of our mini-game, without terrain or character player:

Escoria Main Scene Structure

And here is a more complex example of a main scene with a terrain and a player:

 Escoria second scene structure example

How to go to the next main scene

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"

Transitions between main scenes

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

Play a video between two scenes

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.