mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 09:39:12 +08:00
19 lines
600 B
Dart
19 lines
600 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
|
|
class Aseprite extends BaseGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
final image = await images.load('animations/chopper.png');
|
|
final jsonData = await assets.readJson('images/animations/chopper.json');
|
|
final animation = SpriteAnimation.fromAsepriteData(image, jsonData);
|
|
final spriteSize = Vector2.all(200);
|
|
final animationComponent = SpriteAnimationComponent(
|
|
animation: animation,
|
|
position: (size - spriteSize) / 2,
|
|
size: spriteSize,
|
|
);
|
|
add(animationComponent);
|
|
}
|
|
}
|