import 'package:flame/components.dart'; import 'package:flame/effects.dart'; import 'package:flame/events.dart'; import 'package:flame/input.dart'; import 'package:flutter/material.dart'; class Tile extends SpriteComponent with TapCallbacks { int row; int col; int spriteIndex; final void Function(Tile) onTileTap; Tile({ required Sprite sprite, required this.spriteIndex, required Vector2 size, required Vector2 position, required this.row, required this.col, required this.onTileTap, }) : super(sprite: sprite, size: size, position: position); @override bool onTapDown(TapDownEvent event) { onTileTap(this); return true; } void animateMoveTo(Vector2 newPosition, VoidCallback onComplete) { add(MoveEffect.to( newPosition, EffectController(duration: 0.5), onComplete: onComplete, )); } }