I am working on a simple game using Flame and Flutter. I am following this tutorial: Create a Mobile Game with Flutter and Flame – Beginner Tutorial
But after I added some code following tutorial line:
flameUtil.addGestureRecognizer(tapper);
appears underlined and onTap
function is not working.
API of
flutter-flame
library is constantly evolving and the solution from tutorial above might not work anymore.I had some hard times to re-implement example from this presentation: https://www.youtube.com/watch?v=sFpjEH-ok2s, so you're not alone :-)
Newer versions of
flutter-flame
like0.23.0
, requires to make it work to addTapDetector
mixin to yourBaseGame
class like below:Source: https://github.com/flame-engine/flame/blob/00ad86eb63aa54b411f1d080fec501dd7b671a81/doc/examples/timer/lib/main.dart
Thanks to this your code of BoxGame initialization is just:
without declarations of
Util
andTapGestureRecognizer
.