TextDamageComponent constructor

TextDamageComponent(
  1. String text,
  2. Vector2 position, {
  3. bool onlyUp = false,
  4. TextStyle? config,
  5. double initVelocityVertical = -4,
  6. double initVelocityHorizontal = 1,
  7. double maxDownSize = 20,
  8. double gravity = 0.5,
  9. DirectionTextDamage direction = DirectionTextDamage.RANDOM,
})

Implementation

TextDamageComponent(
  String text,
  Vector2 position, {
  this.onlyUp = false,
  TextStyle? config,
  double initVelocityVertical = -4,
  double initVelocityHorizontal = 1,
  this.maxDownSize = 20,
  this.gravity = 0.5,
  this.direction = DirectionTextDamage.RANDOM,
}) : super(
        text: text,
        textRenderer: TextPaint(
          style: config,
        ),
        position: position,
      ) {
  _initialY = position.y;
  _velocity = initVelocityVertical;
  switch (direction) {
    case DirectionTextDamage.LEFT:
      _moveAxisX = initVelocityHorizontal;
      break;
    case DirectionTextDamage.RIGHT:
      _moveAxisX = initVelocityHorizontal * -1;
      break;
    case DirectionTextDamage.RANDOM:
      _moveAxisX =
          initVelocityHorizontal * Random().nextInt(100) % 2 == 0 ? -1 : 1;
      break;
    case DirectionTextDamage.NONE:
      break;
  }
}