How to update the gravity in flutter flame forge2d?

373 Views Asked by At

I want to update the gravity according to some events in the game, but I can't find a way to change it after I initialise it in the super of the class Forge2DGame.

1

There are 1 best solutions below

1
On BEST ANSWER

You have to use setGravity to change it.

For example:

class MyGame extends Forge2DGame with TapDetector {
  @override
  void onTap() {
    world.setGravity(Vector2(0, 10));
  }
}