moveLeft method

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

Move player to Left

Implementation

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

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

  isIdle = false;
  position = displacement;
  lastDirection = Direction.left;
  lastDirectionHorizontal = Direction.left;
}