Remove FPSCounter from BaseGame (#913)

This commit is contained in:
Lukas Klingsbo
2021-08-10 22:00:52 +02:00
committed by GitHub
parent a93f838483
commit 53fe9e8238
6 changed files with 6 additions and 9 deletions

View File

@ -21,9 +21,6 @@ class MyGame extends Game with FPSCounter {
## BaseGame features ## BaseGame features
If you are using `BaseGame`, you don't have to apply the `FPSCounter` mixin to get access to the
current FPS, because it is already applied by default (so you can use the `fps` method directly).
Flame provides some debugging features for the `BaseGame` class. These features are enabled when Flame provides some debugging features for the `BaseGame` class. These features are enabled when
the `debugMode` property is set to `true` (or overridden to be `true`). the `debugMode` property is set to `true` (or overridden to be `true`).
When `debugMode` is enabled, each `PositionComponent` will be rendered with their bounding size, and When `debugMode` is enabled, each `PositionComponent` will be rendered with their bounding size, and

View File

@ -203,7 +203,7 @@ class CollidableSnowman extends MyCollidable {
} }
class MultipleShapes extends BaseGame class MultipleShapes extends BaseGame
with HasCollidables, HasDraggableComponents { with HasCollidables, HasDraggableComponents, FPSCounter {
final TextPaint fpsTextPaint = TextPaint( final TextPaint fpsTextPaint = TextPaint(
config: TextPaintConfig( config: TextPaintConfig(
color: BasicPalette.white.color, color: BasicPalette.white.color,

View File

@ -33,7 +33,7 @@ class LogoCompomnent extends SpriteComponent with HasGameRef<DebugGame> {
} }
} }
class DebugGame extends BaseGame { class DebugGame extends BaseGame with FPSCounter {
static final fpsTextPaint = TextPaint( static final fpsTextPaint = TextPaint(
config: const TextPaintConfig( config: const TextPaintConfig(
color: Color(0xFFFFFFFF), color: Color(0xFFFFFFFF),

View File

@ -3,13 +3,13 @@ import 'dart:math';
import 'dart:ui'; import 'dart:ui';
import 'package:flame/components.dart' hide Timer; import 'package:flame/components.dart' hide Timer;
import 'package:flame/timer.dart' as flame_timer;
import 'package:flame/game.dart'; import 'package:flame/game.dart';
import 'package:flame/particles.dart'; import 'package:flame/particles.dart';
import 'package:flame/sprite.dart'; import 'package:flame/sprite.dart';
import 'package:flame/timer.dart' as flame_timer;
import 'package:flutter/material.dart' hide Image; import 'package:flutter/material.dart' hide Image;
class ParticlesGame extends BaseGame { class ParticlesGame extends BaseGame with FPSCounter {
/// Defines dimensions of the sample /// Defines dimensions of the sample
/// grid to be displayed on the screen, /// grid to be displayed on the screen,
/// 5x5 in this particular case /// 5x5 in this particular case

View File

@ -29,6 +29,7 @@
- Introduce `scale` on `PositionComponent` - Introduce `scale` on `PositionComponent`
- Add `ScaleEffect` that works on `scale` instead of `size` - Add `ScaleEffect` that works on `scale` instead of `size`
- Add class `NotifyingVector2` - Add class `NotifyingVector2`
- Remove `FPSCounter` from `BaseGame`
## [1.0.0-releasecandidate.13] ## [1.0.0-releasecandidate.13]
- Fix camera not ending up in the correct position on long jumps - Fix camera not ending up in the correct position on long jumps

View File

@ -12,7 +12,6 @@ import '../components/mixins/has_collidables.dart';
import '../components/mixins/has_game_ref.dart'; import '../components/mixins/has_game_ref.dart';
import '../components/mixins/hoverable.dart'; import '../components/mixins/hoverable.dart';
import '../components/mixins/tappable.dart'; import '../components/mixins/tappable.dart';
import '../fps_counter.dart';
import 'camera.dart'; import 'camera.dart';
import 'game.dart'; import 'game.dart';
import 'projector.dart'; import 'projector.dart';
@ -24,7 +23,7 @@ import 'viewport.dart';
/// [update], [render] and [onResize] methods have default implementations. /// [update], [render] and [onResize] methods have default implementations.
/// This is the recommended structure to use for most games. /// This is the recommended structure to use for most games.
/// It is based on the Component system. /// It is based on the Component system.
class BaseGame extends Game with FPSCounter { class BaseGame extends Game {
/// The list of components to be updated and rendered by the base game. /// The list of components to be updated and rendered by the base game.
late final ComponentSet components = createComponentSet(); late final ComponentSet components = createComponentSet();