Skip to content

Commit

Permalink
feat: making debug info visible again (#96)
Browse files Browse the repository at this point in the history
* feat: making debug info visible again

* fixing tests
  • Loading branch information
erickzanardo authored Mar 20, 2024
1 parent f40e05c commit 0264b57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 16 additions & 8 deletions lib/crossword/game/crossword_game.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:ui';

import 'package:flame/components.dart';
import 'package:flame/debug.dart';
Expand Down Expand Up @@ -59,15 +60,22 @@ class CrosswordGame extends FlameGame with PanDetector {
_updateVisibleSections();

if (showDebugOverlay) {
await addAll(
[
FpsComponent(),
FpsTextComponent(),
ChildCounterComponent<SectionComponent>(
position: Vector2(0, 30),
target: world,
await add(
RectangleComponent(
size: Vector2(
200,
50,
),
],
paint: Paint()..color = const Color(0xFF000000),
children: [
FpsComponent(),
FpsTextComponent(),
ChildCounterComponent<SectionComponent>(
position: Vector2(0, 30),
target: world,
),
],
),
);
}
}
Expand Down
8 changes: 5 additions & 3 deletions test/crossword/game/crossword_game_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ void main() {
mockState(state);

await game.ready();
expect(game.firstChild<FpsComponent>(), isNotNull);
expect(game.firstChild<FpsTextComponent>(), isNotNull);
expect(game.descendants().whereType<FpsComponent>(), isNotEmpty);
expect(game.descendants().whereType<FpsTextComponent>(), isNotNull);
expect(
game.firstChild<ChildCounterComponent<SectionComponent>>(),
game
.descendants()
.whereType<ChildCounterComponent<SectionComponent>>(),
isNotNull,
);
},
Expand Down

0 comments on commit 0264b57

Please sign in to comment.