mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-28 11:27:24 +08:00
23 lines
534 B
Dart
23 lines
534 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
|
|
class BasicSpriteExample extends FlameGame {
|
|
static const String description = '''
|
|
In this example we load a sprite from the assets folder and put it into a
|
|
`SpriteComponent`.
|
|
''';
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
final sprite = await loadSprite('flame.png');
|
|
add(
|
|
SpriteComponent(
|
|
sprite: sprite,
|
|
position: size / 2,
|
|
size: sprite.srcSize * 2,
|
|
anchor: Anchor.center,
|
|
),
|
|
);
|
|
}
|
|
}
|