moveUp method

bool moveUp(
  1. double speed, {
  2. bool notifyOnMove = true,
})

Move player to Up

Implementation

bool moveUp(double speed, {bool notifyOnMove = true}) {
  double innerSpeed = speed * dtUpdate;
  Vector2 displacement = position.translate(0, (innerSpeed * -1));

  if (_isCollision(displacement)) {
    if (notifyOnMove) {
      onMove(
        0,
        Direction.up,
        BonfireUtil.getAngleFromDirection(Direction.up),
      );
    }
    return false;
  }

  isIdle = false;
  position = displacement;
  lastDirection = Direction.up;
  if (notifyOnMove) {
    onMove(
      speed,
      lastDirection,
      BonfireUtil.getAngleFromDirection(lastDirection),
    );
  }
  _requestUpdatePriority();
  return true;
}