mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-30 16:36:57 +08:00
Update min Dart constraint to 3.8, which will enable us to use the fancier collection literals. This requires bumping the min Flutter version as well: <img width="1892" height="1122" alt="image" src="https://github.com/user-attachments/assets/7c7b07fc-4d96-4987-824d-9a7133ecfb85" />
57 lines
1.5 KiB
Dart
57 lines
1.5 KiB
Dart
import 'package:examples/commons/ember.dart';
|
|
import 'package:flame/components.dart';
|
|
import 'package:flame/events.dart';
|
|
import 'package:flame/game.dart';
|
|
|
|
class TappableEmber extends Ember with TapCallbacks {
|
|
TappableEmber({required Vector2 position, required Vector2 size})
|
|
: super(position: position, size: size);
|
|
|
|
@override
|
|
bool onTapDown(TapDownEvent event) {
|
|
size += Vector2.all(10);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class ClipComponentExample extends FlameGame {
|
|
static const String description =
|
|
'''Tap on the objects to increase their size and see how the clip component
|
|
works.''';
|
|
|
|
late final _embers = <TappableEmber>[
|
|
TappableEmber(size: Vector2.all(200), position: Vector2.all(100)),
|
|
TappableEmber(size: Vector2.all(300), position: Vector2.all(100)),
|
|
TappableEmber(size: Vector2.all(200), position: Vector2.all(125)),
|
|
];
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
addAll(
|
|
[
|
|
ClipComponent.circle(
|
|
position: Vector2.all(200),
|
|
size: Vector2.all(200),
|
|
children: [_embers[0]],
|
|
),
|
|
ClipComponent.rectangle(
|
|
position: Vector2(600, 200),
|
|
size: Vector2.all(200),
|
|
children: [_embers[1]],
|
|
),
|
|
ClipComponent.polygon(
|
|
points: [
|
|
Vector2(1, 0),
|
|
Vector2(1, 1),
|
|
Vector2(0, 1),
|
|
Vector2(1, 0),
|
|
],
|
|
position: Vector2(200, 500),
|
|
size: Vector2.all(200),
|
|
children: [_embers[2]],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|