Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo committed Nov 16, 2023
1 parent e645ea4 commit 63e4238
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/flame/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ removing it from the tree. This affects the visibility of the component and all
/// Example that implements HasVisibility
class MyComponent extends PositionComponent with HasVisibility {}
/// Usage of the isVisible property
/// Usage of the isVisible property
final myComponent = MyComponent();
add(myComponent);
Expand Down
40 changes: 40 additions & 0 deletions doc/flame/other/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,43 @@ commonly want to show the current FPS somewhere when the `FpsComponent` is used.


[TextComponent]: ../rendering/text_rendering.md#textcomponent

### ChildCounterComponent<T>

`ChildCounterComponent` is a component that can be added to a game and will every second render
the number of children of type `T` from a component. So for example:

```dart
add(
ChildCounterComponent<SpriteAnimationComponent>(
target: world,
),
);
```

Will render the number of `SpriteAnimationComponent` that are children of the game `world`.

### TimeTrackComponent

This component allows developers to track time spent inside their code. This can be useful for
performance debugging time spent in certain parts of the code.

To use it, add it to your game somewhere (since this is a debug feature, we advise to only add the
component in a debug build/flavor):

```dart
add(TimeTrackComponent());
```

Then in the code section that you want to track time, do the following:

```dart
void update(double dt) {
TimeTrackComponent.start('MyComponent.update');
// ...
TimeTrackComponent.end('MyComponent.update');
}
```

With the calls above, the added `TimeTrackComponent` will render the ellapsed time in
microseconds.

0 comments on commit 63e4238

Please sign in to comment.