79745832

Date: 2025-08-25 13:42:51
Score: 0.5
Natty:
Report link
// lib/main.dart
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'package:flame/components.dart';
import 'package:flutter/widgets.dart';

class RunnerGame extends FlameGame with TapDetector {
  late SpriteAnimationComponent hero;

  @override
  Future<void> onLoad() async {
    final image = await images.load('hero_run.png'); // spritesheet
    final animation = SpriteAnimation.fromFrameData(
      image,
      SpriteAnimationData.sequenced(
        amount: 8, stepTime: 0.08, textureSize: Vector2(64, 64),
      ),
    );
    hero = SpriteAnimationComponent(animation: animation, size: Vector2(128, 128))
      ..position = size / 2;
    add(hero);
  }

  @override
  void onTapDown(TapDownInfo info) {
    hero.add(MoveToEffect(info.eventPosition.game, EffectController(duration: 0.3)));
  }
}

void main() {
  final game = RunnerGame();
  runApp(GameWidget(game: game));
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user31349709