Skip to content

Commit 60c5991

Browse files
committed
add onCharacterTyped signal in FlxTypeText which will dispatch when the character changes
1 parent dcd3895 commit 60c5991

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

flixel/addons/text/FlxTypeText.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import flixel.math.FlxMath;
1212
import flixel.system.FlxAssets;
1313
import flixel.text.FlxText;
1414
import flixel.sound.FlxSound;
15+
import flixel.util.FlxSignal;
1516
import flixel.math.FlxRandom;
1617
import openfl.media.Sound;
1718

@@ -110,6 +111,8 @@ class FlxTypeText extends FlxText
110111
*/
111112
public var eraseCallback:Void->Void;
112113

114+
public var onCharacterTyped(default, never):FlxSignal = new FlxSignal();
115+
113116
/**
114117
* The text that will ultimately be displayed.
115118
*/
@@ -439,6 +442,8 @@ class FlxTypeText extends FlxText
439442
_length += Std.int(_timer / delay);
440443
if (_length > _finalText.length)
441444
_length = _finalText.length;
445+
446+
onCharacterTyped.dispatch();
442447
}
443448

444449
if (_erasing && _timer >= eraseDelay)
@@ -516,6 +521,7 @@ class FlxTypeText extends FlxText
516521
if (_length >= _finalText.length && _typing && !_waiting && !_erasing)
517522
{
518523
onComplete();
524+
onCharacterTyped.dispatch();
519525
}
520526

521527
// If we're done erasing, call the onErased() function

0 commit comments

Comments
 (0)