Skip to content

Text Transitions

Wren edited this page Nov 3, 2020 · 1 revision

Text Transitions

What are they?

Text Transitions are a special type of RichTextEffect that give characters a special animation when they appear. This plugin currently comes with a single transition effect, called "fade" ([t_fade]), which is located in the "transitions" folder of the plugin. It causes the text to fade in gently when it appears.

How do I use them?

Before a transition effect is available, you will have to add it to the messagebox you want to use it on, similarly to regular text effects. In this case, you can do that by one of three methods:

  1. Add them in the inspector, in the "Transitions" array. Any included here will be automatically installed when that MessageBox is created.
  2. Using install_transition. This works exactly the same way as install_effect does with effects. Note that you MUST use install_transition and NOT install_effect to install transitions, or they will not be able to run. (install_transition has a little bit of setup magic required to make it work.) RichTextEffects can still be added via all of the standard methods and are completely unaffected by the transitions system.
  3. By setting the transitions variable. Setting it to a new array will completely replace all existing transition effects. Mutation functions are not explicitly supported and may or may not work as expected.

Once a transition is made available, it can be used like any other bbcode tag. Only characters within it will be affected by the transition effect, as per usual.

There are two methods available for removing installed transition effects, although both are currently experimental and untested:

  1. Using remove_transition. Please note that the transition instance passed to this function must be the same instance already installed on the messagebox.
  2. As mentioned above, setting the transitions variable will completely replace the installed transitions, removing any that are not in the new array. NOTE: Directly erasing a transition from custom_effects is not recommended as it may corrupt the node state and cause unexpected behavior.

How do I make one?

For a very simple example, take a look at the included transition script. It is just like an ordinary RichTextEffect, but with a few notable additions:

  • The owner declaration, which should be the same in all transition scripts
  • A non-null check for owner (just to be safe)
  • The use of owner._get_delta Essentially, owner._get_delta is used to query the MessageBox the transition is installed on for the transition progress. owner.get_delta(int ind, float time) returns a float between 0 and 1 representing the percentage of completion the character of ind should display, assuming the animation takes time seconds to complete. In the example effect, this is passed directly to the alpha tint.

Clone this wiki locally