mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-28 23:46:52 +08:00
29 lines
788 B
Dart
29 lines
788 B
Dart
import 'package:examples/commons/ember.dart';
|
|
import 'package:flame/game.dart';
|
|
|
|
class FlipSpriteExample extends FlameGame {
|
|
static const String description = '''
|
|
In this example we show how you can flip components horizontally and
|
|
vertically.
|
|
''';
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
final regular = Ember(position: Vector2(size.x / 2 - 100, 200));
|
|
add(regular);
|
|
|
|
final flipX = Ember(position: Vector2(size.x / 2 - 100, 400));
|
|
flipX.flipHorizontally();
|
|
add(flipX);
|
|
|
|
final flipY = Ember(position: Vector2(size.x / 2 + 100, 200));
|
|
flipY.flipVertically();
|
|
add(flipY);
|
|
|
|
final flipWithRotation = Ember(position: Vector2(size.x / 2 + 100, 400))
|
|
..angle = 2;
|
|
flipWithRotation.flipVertically();
|
|
add(flipWithRotation);
|
|
}
|
|
}
|