updatePosition method
Implementation
void updatePosition(Vector2 position) {
if (collisions.isNotEmpty && position != _lastPosition) {
_lastPosition = position.clone();
Rect? newRect;
for (var element in collisions) {
element.updatePosition(position);
if (newRect == null) {
newRect = element.rect;
} else {
newRect = newRect.expandToInclude(element.rect);
}
}
rect = newRect!;
}
}