update method
void
update({})
Sets any values passed, and runs basic logic:
- if neither
x
ory
are specified, addsvx
/vy
to them - if
age
is not specified, increments it by one
This is provided for convenience, and does not need to be used.
Implementation
void update({
double? x,
double? y,
double? scale,
double? rotation,
int? frame,
Color? color,
double? vx,
double? vy,
double? lifespan,
double? age,
}) {
if (x != null) this.x = x;
if (y != null) this.y = y;
if (scale != null) this.scale = scale;
if (rotation != null) this.rotation = rotation;
if (frame != null) this.frame = frame;
if (color != null) this.color = color;
if (vx != null) this.vx = vx;
if (vy != null) this.vy = vy;
if (lifespan != null) this.lifespan = lifespan;
this.age = age ?? this.age + 1;
if (x == null && y == null) {
this.x += this.vx;
this.y += this.vy;
}
}