runAction method

  1. @override
bool runAction(
  1. double dt,
  2. BonfireGameInterface game
)
override

Implementation

@override
bool runAction(double dt, BonfireGameInterface game) {
  var diffPosition = newPosition - component.position;

  var dtSpeed = component.speed * dt;
  if (diffPosition.x.abs() < dtSpeed && diffPosition.y.abs() < dtSpeed) {
    component.stopMove();
    return true;
  }

  var d = _diffPosition - diffPosition;
  if (d.isZero()) {
    component.stopMove();
    return true;
  }
  _diffPosition = diffPosition;
  var radAngle = atan2(diffPosition.y, diffPosition.x);
  component.moveFromAngle(radAngle);
  return false;
}