Home > Blockchain >  How to update the gravity in flutter flame forge2d?
How to update the gravity in flutter flame forge2d?

Time:10-09

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.

CodePudding user response:

You have to use setGravity to change it.

For example:

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

  • Related