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 autoErase:Bool

Whether or not to erase this message when it is complete.

var cursorBlinkSpeed:Float

The speed at which the cursor should blink, if shown at all.

var cursorCharacter:String

The character to blink at the end of the text.

var delay:Float

The delay between each character, in seconds.

var eraseDelay:Float

The delay between each character erasure, in seconds.

var paused:Bool

Whether or not to animate the text. Set to false by start() and erase().

var prefix:String

Text to add at the beginning, without animating.

var showCursor:Bool

Set to true to show a blinking cursor at the end of the text.

var skipKeys:Array<String>

An array of keys as string values (e.g. "SPACE", "L") that will advance the text.

var sound:FlxSound

The sound that is played when letters are added; optional.

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.

var waitTime:Float

How long to pause after finishing the text before erasing it. Only used if autoErase is true.

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.

function skip():Void

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.

function update():Void