Files
flame/examples/lib/stories/system/resize_example.dart
Luan Nico d4094b2a1b chore: Final tweaks to prepare merging flame_3d (#3381)
Final tweaks to prepare merging flame_3d.

As can be seen [on the merge
PR](https://github.com/flame-engine/flame/pull/3377), we are almost
ready to have a nice diff to merge. This fixes a couple final issues:

* the `.4 -> 0.4` thing that I had copied from main before merging my
fix into main (this will "untouch" that file from the main diff)
* the min flutter version as set by `melos bs` on the flame_3d package
itself
2024-12-11 14:26:29 -05:00

31 lines
709 B
Dart

import 'dart:ui';
import 'package:flame/components.dart';
import 'package:flame/game.dart';
class ResizingRectangle extends RectangleComponent {
ResizingRectangle()
: super(
paint: Paint()..color = const Color(0xFFFE4813),
);
@override
void onGameResize(Vector2 size) {
super.onGameResize(size);
this.size = size * 0.4;
}
}
class ResizeExampleGame extends FlameGame {
ResizeExampleGame() : super(children: [ResizingRectangle()]);
static const description = '''
This example shows how to react to the game being resized.
The rectangle will always be 40% of the screen size.
Try resizing the window and see the rectangle change its size.
''';
}