fix: Remove deprecations for 1.10.0 (#2809)

Removed deprecations for 1.10.0 and fixes some small unreleased regressions found when going through the examples.
This commit is contained in:
Lukas Klingsbo
2023-10-11 15:57:25 +02:00
committed by GitHub
parent 97fff0ed2b
commit 5b67b8f14a
96 changed files with 824 additions and 4925 deletions

View File

@ -2,20 +2,21 @@ import 'dart:math';
import 'package:examples/commons/ember.dart';
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:flame/input.dart';
class BenchmarkExample extends FlameGame with TapDetector {
class BenchmarkExample extends FlameGame {
static const description = '''
See how many SpriteAnimationComponent's your platform can handle before it
starts to drop in FPS, this is without any sprite batching and such.
100 animation components are added per tap.
''';
BenchmarkExample() : super(world: BenchmarkWorld());
final emberSize = Vector2.all(20);
late final TextComponent emberCounter;
final counterPrefix = 'Animations: ';
final Random random = Random();
@override
Future<void> onLoad() async {
@ -40,17 +41,26 @@ starts to drop in FPS, this is without any sprite batching and such.
emberCounter.text =
'$counterPrefix ${world.children.query<Ember>().length}';
}
}
class BenchmarkWorld extends World
with TapCallbacks, HasGameReference<BenchmarkExample> {
final Random random = Random();
@override
void onTapDown(TapDownInfo info) {
world.addAll(
void onTapDown(TapDownEvent event) {
addAll(
List.generate(
100,
(_) => Ember(
size: emberSize,
size: game.emberSize,
position: Vector2(
(size.x / 2) * random.nextDouble() * (random.nextBool() ? 1 : -1),
(size.y / 2) * random.nextDouble() * (random.nextBool() ? 1 : -1),
(game.size.x / 2) *
random.nextDouble() *
(random.nextBool() ? 1 : -1),
(game.size.y / 2) *
random.nextDouble() *
(random.nextBool() ? 1 : -1),
),
),
),