mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 20:13:50 +08:00
* Added Component.childrenFactory * fix some of the lint warnings * more lint warnings * remove changelog entry * more analyzer warnings * one more warning * one more warning * remove more unused imports * fix more warnings * another warning * one more warning * a lot more warnings * some more warnings * fix warnings in flame_svg * fix warnings in flame_bloc * Remove OrderedSet override feature * Remove testRandom change * Remove unnecessary type checks * Re-remove deprecated argument in random_test Co-authored-by: Pasha Stetsenko <stpasha@google.com>
68 lines
1.5 KiB
Dart
68 lines
1.5 KiB
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flame/input.dart';
|
|
import 'package:flame_fire_atlas/flame_fire_atlas.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final game = ExampleGame();
|
|
runApp(GameWidget(game: game));
|
|
}
|
|
|
|
class ExampleGame extends FlameGame with TapDetector {
|
|
late FireAtlas _atlas;
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
_atlas = await loadFireAtlas('caveace.fa');
|
|
add(
|
|
SpriteAnimationComponent(
|
|
size: Vector2(150, 100),
|
|
animation: _atlas.getAnimation('shooting_ptero'),
|
|
)..y = 50,
|
|
);
|
|
|
|
add(
|
|
SpriteAnimationComponent(
|
|
size: Vector2(150, 100),
|
|
animation: _atlas.getAnimation('bomb_ptero'),
|
|
)
|
|
..y = 50
|
|
..x = 200,
|
|
);
|
|
|
|
add(
|
|
SpriteComponent(size: Vector2(50, 50), sprite: _atlas.getSprite('bullet'))
|
|
..y = 200,
|
|
);
|
|
|
|
add(
|
|
SpriteComponent(size: Vector2(50, 50), sprite: _atlas.getSprite('shield'))
|
|
..x = 100
|
|
..y = 200,
|
|
);
|
|
|
|
add(
|
|
SpriteComponent(size: Vector2(50, 50), sprite: _atlas.getSprite('ham'))
|
|
..x = 200
|
|
..y = 200,
|
|
);
|
|
}
|
|
|
|
@override
|
|
void onTapUp(TapUpInfo details) {
|
|
add(
|
|
SpriteAnimationComponent(
|
|
size: Vector2(100, 100),
|
|
animation: _atlas.getAnimation('explosion'),
|
|
removeOnFinish: true,
|
|
)
|
|
..anchor = Anchor.center
|
|
..position = details.eventPosition.game,
|
|
);
|
|
}
|
|
}
|