LucidText is a HaxeFlixel library designed to give easy access to juicy text in the style of games like Paper Mario, Animal Crossing, and Celeste.
This library is designed to allow a user to customize in-game text without needing to touch the code. This is achieved through styling directives embedded directly in the input text as HTML-style tags. The title image at the top of this readme is created by specifying:
Welcome to <wave>LucidText!</wave>
This library comes with various built-in tags, a few of which are:
wave
- A sine wave that moves through the textcolor
- Set the color of the textshake
- Adds a random shake to the text
Tags can also have various attributes that can be set. The wave
, for example, effect has speed
and height
(among others). Using these attributes looks like:
Welcome to <wave height=30 speed=5>LucidText!</wave>
Which would render as:
Effects, which fall into two broad categories: Visual
and Functional
-
Visual Effects cover anything that affects a given set of characters' appearance in a string
- A few examples of Visual Effects:
- One time change such as
color
orsize
- Actively updated Effects such as
wave
andshake
- One time change such as
- Any effects involving motion should avoid using the
FlxTween
engine as that causes strange behavior if the user attempts to move the text object while the tween is active
- A few examples of Visual Effects:
-
Functional Effects cover anything that impacts the process with how characters are added to the screen at a specific point in the string.
- Functional Effects are generally used in
TypingGroup
, with notable examples being:pause
: Imparts a delay when typingpage
: Forces a page break in a given stringcb
: Used as a generally callback to aid in running code at specific points during a string's typing
- These are written as HTML void elements. Examples:
<page/>
and<pause/>
- Functional Effects are generally used in
-
Custom Effects can be be added and used to do anything! See Custom Tags
If the built-in tags are insufficient for a project's needs, custom tags can be eaily added:
- Create a class that implements the
Effect
interface - Register the effect with via the
EffectRegistry.register(...)
function - Any text loaded after registering an effect can use the tag thereafter
One of the hardest parts of using a library like this is knowing what the available options are. To combat this, the current state of the EffectRegistry
can be dumped.
By calling EffectRegistry.dumpToConsole()
will look at the annotations on each registered effect and print out the available information to console. A snippet of this output looks like this:
┌ ───── ┐
│ color │
└ ───── ┘
└ description: [Allows setting the color of characters]
└ parameters
├ rgb
│ └ description: [Color integer formatted as `0xRRGGBB`]
└ alpha
├ range: [0,1]
└ description: [Float value controlling transparency]
This might be better accomplished by a documentation generator in the future.
This project has been set up with MUnit to handle the unit tests. After various failed attempts at getting MUnit working with other projects, this article finally had a simple setup that cooperated well.
haxelib install munit
haxelib install hamcrest
From the test/
directory, simply run lime test neko
and the tests will be executed.
Tests should be put into a class that groups relevant tests together. If these tests are added to a new class, it must be added to the TestSuite.hx
for it to be seen and run by MUnit.
- In
TestSuite.hx
, add a new line to add a class to the test suite withadd(<Class with tests>);
This project uses the formatter
library (this repo) for all formatting.
To install the formatter, run:
haxelib install formatter
To format the source code, run:
haxelib run formatter -s source/