TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrainsExpress::Counters::HealthIcons Class Reference

#include <tbx_health_bar.hpp>

Inheritance diagram for TurtleBrainsExpress::Counters::HealthIcons:
TurtleBrains::Graphics::Graphic

Public Member Functions

 HealthIcons (const tbGraphics::Sprite &fillingSprite, const tbGraphics::Sprite &backingSprite)
 
virtual ~HealthIcons (void)
 
void SetIcons (const tbGraphics::Sprite &fillingSprite, const tbGraphics::Sprite &backingSprite)
 
const tbCore::uint16GetTotal (void) const
 
void SetTotal (const tbCore::uint16 total)
 
const tbCore::uint16GetCount (void) const
 
void SetCount (const tbCore::uint16 count)
 
- Public Member Functions inherited from TurtleBrains::Graphics::Graphic
 Graphic (void)
 
 Graphic (const Graphic &other)
 
virtual ~Graphic (void)
 
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::Vector2GetPosition (void) const
 
void SetPosition (const float x, const float y)
 
void SetPosition (const tbMath::Vector2 &position)
 
const tbMath::Vector2GetOrigin (void) const
 
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::Vector2GetScale (void) const
 
void SetScale (const float scale)
 
void SetScale (const tbMath::Vector2 &scale)
 
void SetScale (const float scaleX, const float scaleY)
 
float GetRotation (void) const
 
void SetRotation (const float rotation)
 
void SetScroll (const float scroll)
 
void SetScroll (const float scrollX, const float scrollY)
 
bool IsRelative (void) const
 
const ColorGetColor (void) const
 
virtual void SetColor (const tbGraphics::Color &newColor)
 
virtual PixelSpace GetPixelWidth (void) const
 
virtual PixelSpace GetPixelHeight (void) const
 
float GetWidth (void) const
 
float GetHeight (void) const
 
float GetScaledWidth (void) const
 
float GetScaledHeight (void) const
 
bool UnstableIsPointContained (const tbMath::Vector2 &point) const
 

Protected Member Functions

virtual void OnRender (void) const override
 
- Protected Member Functions inherited from TurtleBrains::Graphics::Graphic
virtual void OnUpdate (const float deltaTime)
 
virtual void ApplyTransform (void) const
 
virtual void PopTransform (void) const
 

Detailed Description

The HealthIcons object is a counter display that shows an icon over and over, much like the hearts in Legend of Zelda.

Constructor & Destructor Documentation

TurtleBrainsExpress::Counters::HealthIcons::HealthIcons ( const tbGraphics::Sprite fillingSprite,
const tbGraphics::Sprite backingSprite 
)
explicit

Creates the counter object from two sprites representing a filled and backing sprite. The backing sprite will always be rendered, and the filling sprite will be rendered for the given count.

Parameters
fillingSpriteThe sprite to be rendered in front of the backing sprite if the count is high enough.
backingSpriteThe sprite icon to render for each slot (number of slots indicated by GetTotal())
virtual TurtleBrainsExpress::Counters::HealthIcons::~HealthIcons ( void  )
virtual

Destroys the object and cleans up the resources.

Member Function Documentation

const tbCore::uint16& TurtleBrainsExpress::Counters::HealthIcons::GetCount ( void  ) const

Returns the current count, how many active icons are displayed.

const tbCore::uint16& TurtleBrainsExpress::Counters::HealthIcons::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.

virtual void TurtleBrainsExpress::Counters::HealthIcons::OnRender ( void  ) const
overrideprotectedvirtual

Renders the GetTotal() number of backing sprites in a horizontal line and filles some number of them (GetCount()) with the fill sprites.

Implements TurtleBrains::Graphics::Graphic.

void TurtleBrainsExpress::Counters::HealthIcons::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.

Parameters
countThe value of the slider, to be full it would be the same as Total, and to be empty it would be 0.
void TurtleBrainsExpress::Counters::HealthIcons::SetIcons ( const tbGraphics::Sprite fillingSprite,
const tbGraphics::Sprite backingSprite 
)

Changes the icons for the filled and backing sprites.

Parameters
fillingSpriteThe sprite to be rendered in front of the backing sprite if the count is high enough.
backingSpriteThe sprite icon to render for each slot (number of slots indicated by GetTotal())
void TurtleBrainsExpress::Counters::HealthIcons::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.

Parameters
totalThe value it takes for the slider to display as completely full. Must not be 0 or an error condition will be triggered.