diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index 3af3592b..7392cebd 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -12,6 +12,8 @@ import flixel.math.FlxMath; import flixel.system.FlxAssets; import flixel.text.FlxText; import flixel.sound.FlxSound; +import flixel.util.FlxSignal; +import flixel.util.FlxDestroyUtil; import flixel.math.FlxRandom; import openfl.media.Sound; @@ -110,6 +112,11 @@ class FlxTypeText extends FlxText */ public var eraseCallback:Void->Void; + /** + * Dispatches each time a character is typed. + */ + public final onCharacterTyped:FlxSignal = new FlxSignal(); + /** * The text that will ultimately be displayed. */ @@ -439,6 +446,8 @@ class FlxTypeText extends FlxText _length += Std.int(_timer / delay); if (_length > _finalText.length) _length = _finalText.length; + + onCharacterTyped.dispatch(); } if (_erasing && _timer >= eraseDelay) @@ -516,6 +525,7 @@ class FlxTypeText extends FlxText if (_length >= _finalText.length && _typing && !_waiting && !_erasing) { onComplete(); + onCharacterTyped.dispatch(); } // If we're done erasing, call the onErased() function @@ -554,4 +564,10 @@ class FlxTypeText extends FlxText _sound.loadEmbedded(new TypeSound()); #end } + + override public function destroy():Void + { + FlxDestroyUtil.destroy(onCharacterTyped); + super.destroy(); + } }