shake method

void shake({
  1. double intensity = 12,
  2. double frequency = 30,
  3. Duration decay = const Duration(milliseconds: 400),
  4. Offset? direction,
})

Starts (or restarts, discarding any shake already in progress) a decaying oscillation. intensity is the max displacement in logical pixels, frequency in Hz, decay how long until it fully settles to Offset.zero.

direction (IDEA-60) optionally biases the shake toward a collision vector — e.g. a Flame collision callback's own separation/normal vector, passed straight through as an Offset (this widget has zero Flame dependency today and stays that way; a Vector2 from package:flame/vector_math converts trivially via Offset(v.x, v.y), no new import needed here). Left null (the default), the shake keeps its original symmetric elliptical trace — see offsetAt for exactly how the bias is computed.

Implementation

void shake({
  double intensity = 12,
  double frequency = 30,
  Duration decay = const Duration(milliseconds: 400),
  Offset? direction,
}) {
  _intensity = intensity;
  _frequency = frequency;
  _decay = decay;
  _direction = (direction != null && direction.distance > 0)
      ? direction / direction.distance
      : null;
  notifyListeners();
}