moveDown method

void moveDown(
  1. double speed, {
  2. VoidCallback? onCollision,
})

Move player to Down

Implementation

void moveDown(double speed, {VoidCallback? onCollision}) {
  double innerSpeed = speed * dtUpdate;
  Vector2Rect displacement = position.translate(0, innerSpeed);

  if (_isCollision(displacement.position)) {
    onCollision?.call();
    return;
  }

  isIdle = false;
  position = displacement;
  lastDirection = Direction.down;
}