gravity property
Vector2
get
gravity
Don't change the gravity object directly, use the setter instead.
Implementation
Vector2 get gravity => _physicsWorld?.gravity ?? _gravity;
set
gravity
(Vector2? gravity)
Sets the gravity of the world and wakes up all bodies that were created through createBody.
Implementation
set gravity(Vector2? gravity) {
_gravity = gravity ?? defaultGravity;
final existingWorld = _physicsWorld;
if (existingWorld == null) {
// The world picks the gravity up when it is created.
return;
}
existingWorld.gravity = _gravity;
_pruneDestroyedBodies();
for (final body in _bodies) {
body.isAwake = true;
}
}