A Text component that automatically calculates and displays the current FPS.
More...
#include <Counters.h>
|
| | FPS (std::string inStr) |
| | Constructs an FPS counter.
|
| |
| float | calcAvg () |
| | Calculates the average FPS over a sample of frames.
|
| |
| void | update () override |
| | Updates the FPS calculation and the displayed text.
|
| |
| void | reload () override |
| | Resets the frame counter history.
|
| |
| | Text (std::string inStr, int x, int y, float scale, SDL_Color color) |
| | Constructs a fully customized Text component.
|
| |
| | Text (std::string inStr, int x, int y, float scale) |
| | Constructs a Text component with a default color.
|
| |
| | Text (std::string inStr, int x, int y) |
| | Constructs a Text component with a default color and scale.
|
| |
| | Text (std::string inStr, int x, int y, float scale, SDL_Color color) |
| | Constructs a fully customized Text component.
|
| |
| | Text (std::string inStr, int x, int y, float scale) |
| | Constructs a Text component with a default color.
|
| |
| | Text (std::string inStr, int x, int y) |
| | Constructs a Text component with a default color and scale.
|
| |
| void | update () override |
| | Updates the destination rectangle for rendering.
|
| |
| void | draw () override |
| | Draws the text texture to the screen.
|
| |
| void | changeText (std::string text) |
| | Changes the text content and regenerates the texture.
|
| |
| void | centreText (SDL_Rect &parentRect) |
| | Adjusts the text's position to be centered within a parent rectangle.
|
| |
| virtual void | init () |
| | Called once when the component is added to an entity.
|
| |
|
|
int | value |
| | The current FPS value.
|
| |
|
Entity * | entity |
| | Pointer to the entity that owns this component.
|
| |
A Text component that automatically calculates and displays the current FPS.
◆ FPS()
| FPS::FPS |
( |
std::string |
inStr | ) |
|
Constructs an FPS counter.
- Parameters
-
| inStr | The prefix string to display (e.g., "FPS: "). |
◆ calcAvg()
Calculates the average FPS over a sample of frames.
- Returns
- The average frames per second.
◆ reload()
Resets the frame counter history.
Reimplemented from Component.
◆ Text() [1/3]
| Text::Text |
( |
std::string |
inStr, |
|
|
int |
x, |
|
|
int |
y |
|
) |
| |
Constructs a Text component with a default color and scale.
- Parameters
-
| inStr | The initial string to display. |
| x | The x-position. |
| y | The y-position. |
◆ Text() [2/3]
| Text::Text |
( |
std::string |
inStr, |
|
|
int |
x, |
|
|
int |
y, |
|
|
float |
scale |
|
) |
| |
Constructs a Text component with a default color.
- Parameters
-
| inStr | The initial string to display. |
| x | The x-position. |
| y | The y-position. |
| scale | The rendering scale. |
◆ Text() [3/3]
Constructs a fully customized Text component.
- Parameters
-
| inStr | The initial string to display. |
| x | The x-position. |
| y | The y-position. |
| scale | The rendering scale. |
| color | The color of the text. |
◆ update()
Updates the FPS calculation and the displayed text.
Reimplemented from Component.
The documentation for this struct was generated from the following files: