Sites


Creating Point and Click Games with Escoria

Speech Text

When a character speaks, the text is displayed on the screen using a simple UI that can show text with a progressive animation, and animations to open and close the UI, for example a speech bubble. We can use many types of text UI, depending on the situation or the character speaking, and each type of UI can have a different avatar, usually used to show a portrait of the character speaking, but it can be any kind of extra decoration. Speech texts can have a fixed position on the screen, or can have a variable position, in that case they will be placed on top of the character speaking. This chapter describes how to configure a dialog text scene to give some style to your dialogues, and add it to the game.

Speech Display Type: a style for your texts

When showing text, a type of speech text can be specified in esc scripting to define a style for your text. The syntax is as is:

say object text type avatar

so for example we can have:

say bamboo_god "What is the meaning of this!" angry_speech avatar_god

Each type corresponds to a different scene with the nodes that will create a background for your text. If type and avatar are not defined in the esc script, no scene will be used, or the default scene will be used if you created one. So no need to rewrite your esc scripts to add the default type to all your speeches.

Avatars

Avatars are usually used to display a portrait of the character speaking on the UI, but can be used for any kind of decoration. When the dialog text is invoked, an avatar can be specified (if not, the type will be "default").

The avatars pictures are defined inside the dialog type scenes, so the avatars can change depending of the dialog type (or else just repeat them in the different dialog type scenes). Only one avatar type will be visible simultaneously to the speech text.

Speech Type Scene Structure

The structure of a speech text scene is relavitely simple, an example can be found in the file ui/dialog_default.scn. The requirements are:

  • A root node of type Node2D, with the script globals/dialog_instance.gd attached to it. The script has 1 parameter, "fixed_pos". When this checkbox is selected, your speech will have a fixed position, and it will not be placed on top of the character that is speaking. It will simply be placed in the scene at position 0,0
  • A node of type Node2D named "anchor". This is used by the animation to move and scale the structure of the whole scene.
  • A node of type RichTextLabelnamed "text", child of "anchor". This is where the text will be displayed. Remember to configure the fonts here.
  • A node of type Node2D named "avatars", child of the "anchor" node. This node can have one or more children, usually of type Sprite with different avatars. The name of the node will be used as the avatar type. When an avatar is specified, the node with a name that matches the avatar type will be shown, everything else will be hidden.
  • Optionally a node of type AnimationPlayer named "animation", that can contain 2 animations, "show" and "hide". If found, these are executed when the dialog opens and closes.

So the looks like this:

 Escoria Dialog scene structure

And here is an example of a default scene with our mini-game:

Escoria Dialog scene type example

A list of speech type scenes for your game

The list of speech type scenes are configured in a containing scene, found in globals/dialog_player.scn. This list scene contain a ResourcePreloader node, meaning it preloads the resource for each of the available dialog scenes. The name of the resource will be used to identify the type of the speech.

Escoria dialog player scene

Here is an example of the minimal container scene, the list is created in the bottom central panel, open your dialog type scene with the folder icon and give it the correct name. Remember to always add a "default" speech type, and any additional types you'd like to use.

Fonts and text styles

As we said, the font of your text is defined in the RichTextLabel node named "text". To add a font to your dialogs, you first have to import your font in Godot (Import > Font in the top right menu), so it can be converted to a texture font.

Escoria Import font

Here is an example of the texture font of our mini-game:

Escoria texture font example

For details, see the Godot documentation about Importing font : http://docs.godotengine.org/en/latest/tutorials/asset_pipeline/importing_fonts.html

BBCode

If you have several font style (Italic, bold, and so on) and you imported them in Godot and specified them in the RichTextLabel node, you can use the BBCode markup language (originally used in message boards) inside your esc script to style you text. In this example, the "Made in China" sentence will be rendered italic:

say bamboo_god "What is the meaning of this! [i]“Made in China”?![/i] 
Be wary of my wrath as I shall curse you and all your lineage!"

For details on how to add BBcode in your esc scripts see the Godot documentation: http://docs.godotengine.org/en/latest/reference/bbcode_in_richtextlabel.html

And for a list of BBCode markups, see the Wikipedia page on BBCode : https://en.wikipedia.org/wiki/BBCode

Customizing tooltips

In the same way, you can also give a font and a style to your tooltips by customizing the "tooltip" Label node in the ui/hud.scn file.

Escoria tooltip customization

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.