mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-14 03:40:21 +08:00
* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631) * Move files to src and comply with the dart package layout convention * Fixing widgets example Co-authored-by: Serge Matveenko <lig@countzero.co> Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
30 lines
714 B
Dart
30 lines
714 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() async {
|
|
runApp(
|
|
GameWidget(
|
|
game: MyGame(),
|
|
),
|
|
);
|
|
}
|
|
|
|
class MyGame extends BaseGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
final image = await images.load('chopper.png');
|
|
final jsonData = await assets.readJson('chopper.json');
|
|
final animation = SpriteAnimation.fromAsepriteData(
|
|
image,
|
|
jsonData,
|
|
);
|
|
final spriteSize = Vector2.all(200);
|
|
final animationComponent =
|
|
SpriteAnimationComponent.fromSpriteAnimation(spriteSize, animation)
|
|
..position = size / 2 - Vector2.all(100);
|
|
|
|
add(animationComponent);
|
|
}
|
|
}
|