class flixel.addons.text.FlxTypeText extends FlxText
Available on all platforms
This is loosely based on the TypeText class by Noel Berry, who wrote it for his Ludum Dare 22 game - Abandoned * http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=1527 * @author Noel Berry
Instance Fields
var useDefaultSound:Bool
If this is set to true, this class will use typetext.wav from flixel-addons for the type sound unless you specify another.
function new(X:Float, Y:Float, Width:Int, Text:String, ?Size:Int = 8, ?EmbeddedFont:Bool = true):Void
Create a FlxTypeText object, which is very similar to FlxText except that the text is initially hidden and can be * animated one character at a time by calling start(). * *
X | The X position for this object. * |
Y | The Y position for this object. * |
Width | The width of this object. Text wraps automatically. * |
Text | The text that will ultimately be displayed. * |
Size | The size of the text. * |
EmbeddedFont | Whether this text field uses embedded fonts or not. |
function erase(?Delay:Float = null, ?ForceRestart:Bool = false, ?Sound:FlxSound = null, ?SkipKeys:Array<String> = null, ?Callback:Dynamic = null, ?Params:Array<Dynamic> = null):Void
Begin an animated erase of this text. * *
Delay | Optionally, set the delay between characters. Can also be set separately. * |
ForceRestart | Whether or not to start this animation over if currently animating; false by default. * |
Sound | A FlxSound object to play when a character is typed. Can also be set separately. * |
SkipKeys | An array of keys as string values (e.g. "SPACE", "L") that will advance the text. Can also be set separately. * |
Callback | An optional callback function, to be called when the erasing animation is complete. * |
Params | Optional parameters to pass to the callback function. |
function resetText(Text:String):Void
Reset the text with a new text string. Automatically cancels typing, and erasing. * *
Text | The text that will ultimately be displayed. |
function setCompleteCallback(Callback:Dynamic, ?Params:Array<Dynamic> = null):Void
Set a function to be called when typing the message is complete. * *
Callback | The callback function. * |
Params | Any params you want to pass to the function. Optional! |
function setEraseCallback(Callback:Dynamic, ?Params:Array<Dynamic> = null):Void
Set a function to be called when erasing is complete. * Make sure to set erase = true or else this will never be called! * *
Callback | The callback function. * |
Params | Any params you want to pass to the function. Optional! |
function setSkipKeys(Keys:Array<String>):Void
Define the keys that can be used to advance text. * *
Keys | An array of keys as string values (e.g. "SPACE", "L") that will advance the text. |
function setSound(Sound:FlxSound):Void
Set a sound that will be played each time a letter is added to the text. * *
Sound | A FlxSound object. |
function setTypingVariation(?Amount:Float = 0.5f, ?On:Bool = true):Void
If called with On set to true, a random variation will be added to the rate of typing. * Especially with sound enabled, this can give a more "natural" feel to the typing. * Much more noticable with longer text delays. * *
Amount | How much variation to add, as a percentage of delay (0.5 = 50% is the maximum amount that will be added or subtracted from the delay variable). Only valid if >0 and <1. * |
On | Whether or not to add the random variation. True by default. |
Immediately finishes the animation. Called if any of the skipKeys is pressed. * Handy for custom skipping behaviour (for example with different inputs like mouse or gamepad).
function start(?Delay:Float = null, ?ForceRestart:Bool = false, ?AutoErase:Bool = false, ?Sound:FlxSound = null, ?SkipKeys:Array<String> = null, ?Callback:Dynamic = null, ?Params:Array<Dynamic> = null):Void
Start the text animation. * *
Delay | Optionally, set the delay between characters. Can also be set separately. * |
ForceRestart | Whether or not to start this animation over if currently animating; false by default. * |
AutoErase | Whether or not to begin the erase animation when the typing animation is complete. Can also be set separately. * |
Sound | A FlxSound object to play when a character is typed. Can also be set separately. * |
SkipKeys | An array of keys as string values (e.g. "SPACE", "L") that will advance the text. Can also be set separately. * |
Callback | An optional callback function, to be called when the typing animation is complete. * |
Params | Optional parameters to pass to the callback function. |