How can I set the maximum frame rate in Flutter Flame?
It seems that it's not mentioned in the documentation. I couldn't find it. Is it not possible to change it?
https://docs.flame-engine.org/main/index.html
Are you saying that since we get delta time, it's not really an issue?
You usually don't want to do this, usually you want to build your code dependent on the delta time (dt
) that you get in the update
methods.
But if you really want to set a fixed update rate (not the same as frame rate, but it should most likely not matter for your use-case) you can override updateTree
in your game class:
class MyGame extends FlameGame {
var _dtSum = 0.0;
final fixedRate = 1/60; // 60 updates per second
@override
void updateTree(double dt) {
_dtSum += dt;
if(_dtSum > fixedRate) {
super.updateTree(fixedRate);
_dtSum -= fixedRate;
}
}
}