|
|
7 gadi atpakaļ | |
|---|---|---|
| readme_files | 7 gadi atpakaļ | |
| sample | 7 gadi atpakaļ | |
| textbox | 7 gadi atpakaļ | |
| .gitignore | 7 gadi atpakaļ | |
| README.md | 7 gadi atpakaļ |
Include the library's root folder as classpath in your project node. Something like (as 2018-04-16)
<project>
<!-- Here goes some of your configuration -->
<classpath name="path to the library's folder." />
<!-- Here goes some of your configuration -->
Now you should be ready and able to require classes such as textbox.Textbox.
new (Float, Float, Settings) : Creates a textbox where top-left corner is placed in (X,Y). Additional settings are stored in the given Settings object.bring () : activates the textbox and its process, making it appear in-game.dismiss () : deactivates the textbox and makes it disappear in-gamesetText (String) : parses the string's content and prepares itself for the next use.continueWriting () : if the textbox is full, this function acknowledges it and asks the textbox to continue writing text (by moving up the text and writing in the newly empty last line)NOTE : This is under WIP as it might change between versions.
Callbacks are useful as they allow you to extend the textbox without touching its logic. It allowed me to extract the textbox's logic from my now-dead project and make it easy to add features over it, features like effects, triggering a sound per character added to the box or change how it deals with the siutation when the textbox is full.
A few callback ideas (chaining boxes, sound-per-character, text character) are shown in the given sample project.
statusChangeCallback (Status) : if the textbox's state changes, this callback is called. Here a list of the expected behavior to be notifed of:
FULL : the textbox is full. Coupled with continueWriting you can make stuff like waiting a button press to resume writing.DONE : the textbox finished writing its content. You can dismiss it or set it with new text.characterDisplayCallback (textbox.Text) : This callback is added each time a character is added to the box. Use this if you need features like an audio sample played for every character, a text cursor following the input, etc etc...typedef Settings = {
font:String,
fontSize: Int,
textFieldWidth:Float,
color: FlxColor,
?numLines:Int, // Default is currently 3
?charactersPerSecond:Float, // Default is currently 24
};
This textbox allows for per-character effects such as (but not limited to) coloring text or making an animated rainbow. Those effects are enabled and disabled by in-text code sequences that are small and human-writable.
var textbox:Textbox = new Textbox(...);
textbox`.setText("
I'm enabling effect n°00 with arguments (0x00, 0x00, 0x00) : @001000000
I'm disabling effect n°05 @050
I'm enabling multiple effects : @0010A0C0E@0510DCCDE...
It even works inside wo@001000000rds, even if it's a bit unreadable...
");
@MM1AABBCC
▲│ │ │ │
└┼Sequence start ()
│ │ │ │
└ Effect n° 0xMM
│ │ │
│ │ │
└ Argument 1 : 0xAA
│ │
└ Argument 2 : 0xAA
│
└ Argument 3 : 0xAA
@MM0
▲│
└┼Sequence start ()
│
└ Effect n° 0xMM
Note : The 0 or 1 between the effect index and the first argument indicates the textbox parser to disable or enable said effect
NOTE : This is under WIP as it might change between versions.
To add an effect to the effect list, you have to create a class implementing IEffect and add it to TextEffectArray's effectClasses variables. Two effects currently are already implemented : coloring some text and an animated rainbow effect. The effect's position index in the array will be it's code sequence's ID.
reset(Int, Int, Int, nthCharacter:Int):Void : called when the effect is enabled on a character. (It's named reset as an effect can be set multiple times.)update(Float) : the good old classic update function, called by the textbox on a FlxState.update() tick or manual update.apply(Float) : called on a character's own update function to update the character's look if needed.setActive(Bool)/isActive():Bool : (WIP) implement those to correctly manage the effect's activated's state. A simple get/set is enough.The library's pretty much functionnal and gives the barebones features as now (the current effects comes from my dead project as freebies). Here's a non-exhaustive list of what could be added or changed to make the users' life easier :