long story short. I'm using flame engine inside expanded widget. Right now I'm loading six backgrounds as well as my SpriteComponent class inside Game extending FlameGame with HasTappableComponents. Now I want to add some interaction to this SpriteComponent, like reaction to tapping or switch animation while no tapping takes place. I don't understand why it doesn't even print that 'tap down'...
class FoxCharacter extends SpriteComponent with Tappable, HasGameRef {
String working = "like a charm";
late SpriteAnimation animation;
late SpriteAnimationComponent animationComponent2;
Future<void> onLoad() async {
super.onLoad();
animation = await gameRef.loadSpriteAnimation(
'fox.png',
SpriteAnimationData.sequenced(
amount: 8,
textureSize: Vector2(64.0, 59.0),
stepTime: 0.15,
),
);
animationComponent2 = SpriteAnimationComponent(
animation: animation,
size: Vector2(200.0, 200.0),
position:Vector2(gameRef.size.x / 2 - 50, gameRef.size.y - 215),
);
add(animationComponent2);
print(working);
}
@override
bool onTapDown(TapDownInfo event) {
print("tap down");
return true;
}
}
I tried to change final to late and some other dull ideas with no results. How can I add interaction to this FoxCharacter? Is this possible that it cannot be used in SpriteComponent and only PositionComponent?