Files
flame/doc/examples/aseprite/lib/main.dart
Renan ccee9a466b Move files to src and comply with the dart package layout convention (#621)
* 👌 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>
2021-01-20 09:05:43 -03:00

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);
}
}