Text.hx 736 B

12345678910111213141516171819202122232425262728293031323334
  1. package textbox;
  2. import flixel.text.FlxText;
  3. import textbox.effects.IEffect;
  4. class Text extends FlxText {
  5. public var effects:Array<IEffect>;
  6. public override function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?text:String, Size:Int = 8, EmbeddedFont:Bool = true)
  7. {
  8. super(X, Y, FieldWidth, text, EmbeddedFont);
  9. effects = [];
  10. for (effect in TextEffectArray.effectClasses)
  11. {
  12. effects.push(Type.createInstance(effect, []));
  13. }
  14. }
  15. public function clear()
  16. {
  17. this.offset.set(0,0);
  18. }
  19. override public function update(elapsed:Float)
  20. {
  21. for (effect in effects)
  22. {
  23. if (effect.isActive())
  24. {
  25. effect.update(elapsed);
  26. effect.apply(this);
  27. }
  28. }
  29. }
  30. }