#include <tbx_parallax_backdrop.h>
Public Types | |
enum | ScrollingType { ScrollingType::kNoScrolling, ScrollingType::kHorizontal, ScrollingType::kVertical, ScrollingType::kFullScrolling } |
Public Member Functions | |
ParallaxBackdrop (const ScrollingType &scrollingType=ScrollingType::kNoScrolling) | |
virtual | ~ParallaxBackdrop (void) |
void | AddParallaxLayer (const tbCore::tbString &layerFilepath, const float parallaxMultiplier, const tbMath::Vector2 &offset=tbMath::Vector2::Zero()) |
ScrollingType | GetScrollingType (void) const |
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::Vector2 & | GetPosition (void) const |
void | SetPosition (const float x, const float y) |
void | SetPosition (const tbMath::Vector2 &position) |
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 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 Color & | GetColor (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 |
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 |
The ParallaxBackdrop object takes a collection of sprites to have a depth/parallax effect when the object moves. It supports endless Horizontal or Vertical scrolling, Omni Directional scrolling or if desired no scrolling for menu like effects.
|
explicit |
Constructs an empty ParallaxBackdrop with the specified scrolling type.
scrollingType | The direction of endless scrolling that the backdrop should have. |
|
virtual |
Cleans-up after the ParallaxBackdrop object and any sprite resources it used.
void TurtleBrainsExpress::Graphics::ParallaxBackdrop::AddParallaxLayer | ( | const tbCore::tbString & | layerFilepath, |
const float | parallaxMultiplier, | ||
const tbMath::Vector2 & | offset = tbMath::Vector2::Zero() |
||
) |
Add a new layer to the parallax effect for the backdrop. Each layer will perform the endless scrolling for itself adding slightly more computation time and fill-rate for graphics, although the layer will draw the minimum number of times to perform scrolling expected of the backdrop. Each time a new layer is added, it will be added in front of all previous layers.
layerFilepath | The path of the file to load as a sprite that will be used for this layer of the backdrop, minimum size is 100x100px although smaller sprites will incur more performance overhead. |
parallaxMultiplier | Essentially the amount of movement the layer will have, 0 would keep the layer from moving at all, and 1 would move at the same rate of speed as the backdrop object moves. |
offset | If desired this will allow the layer to be offset positionally. |
|
inline |
Returns the scrolling of type of the backdrop object.
|
overrideprotectedvirtual |
Overrides OnRender() to be capable of endlessly scrolling each layer as the backdrop moves, depending on the scroll type of the backdrop object.
Implements TurtleBrains::Graphics::Graphic.