mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
This upgrades all packages to Flutter 3.0.0 and fixes all analyze issues that came from that.
29 lines
636 B
Dart
29 lines
636 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class MyGameWidget extends StatelessWidget {
|
|
const MyGameWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GameWidget(game: MyGame());
|
|
}
|
|
}
|
|
|
|
class Background extends SpriteComponent with HasGameRef<MyGame> {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
sprite = await gameRef.loadSprite('city.png');
|
|
size = Vector2.all(200);
|
|
position = Vector2.all(100);
|
|
}
|
|
}
|
|
|
|
class MyGame extends FlameGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await add(Background());
|
|
}
|
|
}
|