mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 01:18:38 +08:00
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:
@ -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),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user