New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add TimeTrackComponent and ChildCounterComponent #2846
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, no harm in providing debug helpers!
Maybe they could reside in a subdirectory, like components/debug
or something like that?
import 'package:flame/components.dart'; | ||
import 'package:flame/text.dart'; | ||
|
||
class ComponentTrackComponent<T> extends TextComponent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a confusing name 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is so freaking confusing hahaha, but like I just submitted this as it was based on my perfomance debugging, and I was not really caring about names hahahahaha
Maybe ChildTrackComponent
? Since this will track the number of a certain child of a parent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ngl, the first time I read this I thought it was about a race car game! Since I interpreted "track" as the "race track" 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ChildTrackComponent?
I don't think that really conveys what it does either, maybe ChildCounterComponent
or something like that?
static final Map<String, int> _startTimes = {}; | ||
static final Map<String, int> _endTimes = {}; | ||
|
||
static void clear() { | ||
_startTimes.clear(); | ||
_endTimes.clear(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, do we really want all these to be static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is also part of the rough implementation. But at the same time, I thought that keeping then static would make the tracking be less impactful and make the tracking more accurate? But anyhow totally open to suggestion, at the time I just did it static because I needed something quick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if it is an explicit debug component it can probably just be kept as static, since debugging is supposed to be "quick & dirty" anyways.
I'm in favour of moving debug components to a |
hum, yeah, that is a fair argument, right now the fps component is also "loose" in the directory |
I don't think we have to prefix every component with debug, but we could skip exporting them in |
9402d5a
to
63e4238
Compare
doc/flame/other/debug.md
Outdated
); | ||
``` | ||
|
||
Will render the number of `SpriteAnimationComponent` that are children of the game `world`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to merge this with "So for example:" and put it above the code, since it sounds like it is continuing that sentence.
So for example, the following will render the number of
SpriteAnimationComponent
that are children of the gameworld
:
packages/flame/lib/components.dart
Outdated
@@ -48,6 +49,7 @@ export 'src/components/sprite_group_component.dart'; | |||
export 'src/components/text_box_component.dart'; | |||
export 'src/components/text_component.dart'; | |||
export 'src/components/text_element_component.dart'; | |||
export 'src/components/time_track_component.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to a debug.dart
barrel file like we discussed :)
@@ -0,0 +1,65 @@ | |||
import 'dart:async'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a subdirectory inside component
called debug
too where these can live? And eventually we can move over other ones too, like the ones tracking fps (probably add those to the debug barrel file too).
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Description
Adds
TimeTrackComponent
and aChildCounterComponent
to help developers track down perfomance issues in their game.Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Related Issues
Replace or remove this text.