TextDamageComponent constructor

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

Implementation

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