update method

  1. @override
void update()
override

Implementation

@override
void update() {
  position.add(velocity);
  var distance = basePosition.distanceTo(position);
  if (distance > 50 || distance <= -50) {
    velocity = -velocity;
  }
}