From 63e423866ae58abeb0d54cf38f8061d8aa77383b Mon Sep 17 00:00:00 2001 From: Erick Date: Thu, 16 Nov 2023 14:27:35 -0300 Subject: [PATCH] docs --- doc/flame/components.md | 2 +- doc/flame/other/debug.md | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/flame/components.md b/doc/flame/components.md index 36d14dc511a..74b101e7e81 100644 --- a/doc/flame/components.md +++ b/doc/flame/components.md @@ -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); diff --git a/doc/flame/other/debug.md b/doc/flame/other/debug.md index 0ba3cb3eb4c..3cb0ea9b89c 100644 --- a/doc/flame/other/debug.md +++ b/doc/flame/other/debug.md @@ -35,3 +35,43 @@ commonly want to show the current FPS somewhere when the `FpsComponent` is used. [TextComponent]: ../rendering/text_rendering.md#textcomponent + +### ChildCounterComponent + +`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( + 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.