#include <tbx_health_bar.hpp>
Public Member Functions | |
| HealthBar (const tbGraphics::Color &fillColor=tbGraphics::ColorPalette::Green, const tbGraphics::Color &backColor=tbGraphics::ColorPalette::Black) | |
| virtual | ~HealthBar (void) |
| void | SetSize (const tbGraphics::PixelSpace &width, const tbGraphics::PixelSpace &height) |
| const tbCore::uint16 & | GetTotal (void) const |
| void | SetTotal (const tbCore::uint16 total) |
| const tbCore::uint16 & | GetCount (void) const |
| void | SetCount (const tbCore::uint16 count) |
| void | SetFillColor (const tbGraphics::Color &fillColor) |
| virtual tbGraphics::PixelSpace | GetPixelWidth (void) const override |
| virtual tbGraphics::PixelSpace | GetPixelHeight (void) const override |
Public Member Functions inherited from TurtleBrains::Graphics::Graphic | |
| Graphic (void) | |
| Graphic (const Graphic &other)=default | |
| virtual | ~Graphic (void)=default |
| Graphic & | operator= (const Graphic &other)=default |
| bool | IsActive (void) const |
| void | SetActive (const bool isActive) |
| void | Update (const float deltaTime) |
| bool | IsVisible (void) const |
| void | SetVisible (const bool isVisible) |
| void | Render (void) const |
| const tbMath::Vector2 & | GetPosition (void) const |
| void | SetPosition (const float x, const float y) |
| void | SetPosition (const tbMath::Vector2 &position) |
| const tbMath::Vector2 & | GetOrigin (void) const |
| void | SetOrigin (const AnchorLocation &anchor, const float offsetX, const float offsetY) |
| void | SetOrigin (const AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero()) |
| void | SetOrigin (const float originX, const float originY) |
| void | SetOrigin (const tbMath::Vector2 &origin) |
| float | GetDepth (void) const |
| void | SetDepth (const float newDepth) |
| const tbMath::Vector2 & | GetScale (void) const |
| void | SetScale (const float scale) |
| void | SetScale (const tbMath::Vector2 &scale) |
| void | SetScale (const float scaleX, const float scaleY) |
| tbMath::Angle | GetRotation (void) const |
| void | SetRotation (const tbMath::Angle &angle) |
| void | SetScroll (const float scroll) |
| void | SetScroll (const float scrollX, const float scrollY) |
| bool | IsRelative (void) const |
| const Color & | GetColor (void) const |
| virtual void | SetColor (const tbGraphics::Color &newColor) |
| float | GetWidth (void) const |
| float | GetHeight (void) const |
| float | GetScaledWidth (void) const |
| float | GetScaledHeight (void) const |
| tbMath::Vector2 | GetAnchorPosition (const tbGraphics::AnchorLocation &anchor, const float offsetX, const float offsetY) const |
| tbMath::Vector2 | GetAnchorPosition (const tbGraphics::AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero()) const |
| bool | UnstableIsPointContained (const tbMath::Vector2 &point) const |
Protected Member Functions | |
| virtual void | OnUpdate (const float deltaTime) override |
| virtual void | OnRender (void) const override |
Protected Member Functions inherited from TurtleBrains::Graphics::Graphic | |
| virtual void | ApplyTransform (void) const |
| virtual void | PopTransform (void) const |
Provides a simple sliding UI element that acts like a health bar.
|
explicit |
Constructs the HealthBar object via two BoxShapes of different color.
| fillColor | The color of the inner bar that represents the counter / health amount that is available in the given counter. |
| backColor | The color surrounding the inner fill to show the available area. |
|
virtual |
Destroys the object and cleans up resources.
| const tbCore::uint16& TurtleBrains::Express::Counters::HealthBar::GetCount | ( | void | ) | const |
Returns the current value of the counter.
|
overridevirtual |
Returns the height in pixel-space of the health bar, which is the size of the backing / border area, not the intter fill.
Reimplemented from TurtleBrains::Graphics::Graphic.
|
overridevirtual |
Returns the width in pixel-space of the health bar, which is the size of the backing / border area, not the intter fill.
Reimplemented from TurtleBrains::Graphics::Graphic.
| const tbCore::uint16& TurtleBrains::Express::Counters::HealthBar::GetTotal | ( | void | ) | const |
Returns the total value of the counter which can be set via SetTotal() the percentage of GetCount() / GetTotal() determines the display of the slider.
|
overrideprotectedvirtual |
Renders the BoxShapes the make up the slider bar.
Implements TurtleBrains::Graphics::Graphic.
|
overrideprotectedvirtual |
Updates the size of the BoxShapes if the the Total or Count has been changed since previous frame.
Reimplemented from TurtleBrains::Graphics::Graphic.
| void TurtleBrains::Express::Counters::HealthBar::SetCount | ( | const tbCore::uint16 | count | ) |
Sets the current value of the counter which will change how the slider is displayed. The count must be less-than-or-equal-to the total. There will not be an error condition triggered though a warning may be displayed.
| count | The value of the slider, to be full it would be the same as Total, and to be empty it would be 0. |
| void TurtleBrains::Express::Counters::HealthBar::SetFillColor | ( | const tbGraphics::Color & | fillColor | ) |
Sets the color of the fill that shows how full/empty the counter is.
| void TurtleBrains::Express::Counters::HealthBar::SetSize | ( | const tbGraphics::PixelSpace & | width, |
| const tbGraphics::PixelSpace & | height | ||
| ) |
Set the size to your desired size in pixels.
| width | The horizontal width of the health bar in pixel-space. |
| height | The vertical height of the health bar in pixel-space. |
| void TurtleBrains::Express::Counters::HealthBar::SetTotal | ( | const tbCore::uint16 | total | ) |
Sets the total value of the counter to determine the display of the slider. The value is a 16bit unsigned value. If the new total is less than the current count, the count will be lowered to match the new total.
| total | The value it takes for the slider to display as completely full. Must not be 0 or an error condition will be triggered. |