Working with text in gooey
As described in the Fundamentals of gooey tutorial, gooey relies on ScribbleDX for rendering text elements. This article explains how these two interact.
Each release of gooey comes bundled with a specific version of ScribbleDX. You can check the specific version included by looking at the .YYMPS name or by looking at the GameMaker log when you run your game (check out a Scribble message such as the following:
Text formatting
When providing text to a gooey widget, we provide a string that can include inline tags for formatting. In general, gooey text will be rendered internally using the scribble constructor, which expects a string with tags. The most commonly used tags are the following:
| Category | Open Tag | Close Tag | Meaning |
|---|---|---|---|
| Color | [<name of color>] / [#<hex>] |
[/color] |
Sets the color of the text and the blend color for the inline sprites within the enclosed region |
| Alpha | [alpha, <value>] |
[/alpha] |
Sets the alpha of the text and inline sprites within the enclosed region |
| Sprites | [<name of sprite>,<optional image>,<optional speed>] |
N/A | Inserts an inline sprite, with optional frame number (0 by default) and optional speed (SCRIBBLE_DEFAULT_SPRITE_SPEED speed by default) |
| Horizontal Text Alignment | [fa_left] / [fa_center] / [fa_right] |
N/A | Sets the horizontal alignment for the complete string |
| Vertical Text Alignment | [fa_top] / [fa_middle] / [fa_bottom] |
N/A | Sets the vertical alignment for the complete string |
| Font | [<font name>] |
[/font] |
Sets the text font within the enclosed region |
| Size | [scale, <factor>] |
[/scale] |
Sets the scale of the text and inline sprites within the enclosed region |
| Effects | [wave] / [shake] / [wobble] / [pulse] / [wheel] / [jitter] / [blink] / [rainbow] |
[/wave] / [/shake] / [/wobble] / [/pulse] / [/wheel] / [/jitter] / [/blink] / [/rainbow] |
Sets up different text effects within the enclosed region |
ScribbleDX
The above list is a non-exhaustive list, based on ScribbleDX 9.5.0 at the time of writing this article. Always refer to the the official ScribbleDX documentation and make sure to select the docs for your individual ScribbleDX version.
Widget format variables vs text variables
Some widgets in gooey have separate string format variables you can set that affect the formatting of the rendered text; others (such as UIText) rely on you specifying the formatting tags directly inside the string.
If you supply both, they will be combined. In this case, make sure to check the order of tags, as this will affect the final output.
Anchor points vs text formatting
As described in the anchor points article, setting an anchor point for a widget does not modify its text formatting. This means, for example, setting a widget to be aligned and originating to the BOTTOM_RIGHT anchor point does not automatically mean the widget text will be aligned with [fa_right] and [fa_bottom]. You need to set this up manually - and this gives you total control on exactly how the widget is rendered.
About typists
As of today, typists (ScribbleDX's implementation of typewriter effects) are only supported in text widgets (UIText). Please check out the Text widget documentation to know more about how to set them correctly.
ScribbleDX configuration variables modified
Each version of gooey that comes with a corresponding version of ScribbleDX has some configuration variables that have been modified. These are the current ones:
SCRIBBLE_DEFAULT_COLORis set toc_whiteinstead ofc_blackSCRIBBLE_DEFAULT_HALIGNis set tofa_centerinstead offa_leftSCRIBBLE_DEFAULT_VALIGNis set tofa_middleinstead offa_topSCRIBBLE_ALLOW_TEXT_GETTERis set totrueinstead offalse
Other ScribbleDX methods and features
There are tons of other ScribbleDX features, many of which can be used in conjunction with gooey directly. For example, tou can set the default font by using scribble_font_set_default, saving you from having to manually include font tags for the majority of the strings.
Please note that actual rendering of elements is called internally. This means that methods such as draw cannot be manually called, or chained together with other methods - unless you modify the internal gooey scripts.