class EE::Graphics::ScrollParallax

Overview

The scroll parallax renders a TextureRegion to the screen from a position and a size specified. If the size is bigger than the TextureRegion, the TextureRegion is rendered as a repeated TextureRegion until it covers all the size of the parallax, adding movement to more than one Scroll Parallax will generate the ilusion of depth. * More info in wikipedia: http://en.wikipedia.org/wiki/Parallax_scrolling. More…

#include <scrollparallax.hpp>

class ScrollParallax {
public:
    // construction

    ScrollParallax();
    ScrollParallax(TextureRegion* textureRegion, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendMode::Alpha());
    ~ScrollParallax();

    // methods

    bool create(TextureRegion* textureRegion, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendMode::Alpha());
    void setColor(const Color& Color);
    Color getColor() const;
    void setBlendMode(const BlendMode& Blend);
    const BlendMode& getBlendMode() const;
    void draw();
    void setSize(const Sizef& size);
    const Sizef& getSize() const;
    void setPosition(const Vector2f& Pos);
    const Vector2f& getPosition() const;
    TextureRegion* getTextureRegion() const;
    void setTextureRegion(TextureRegion* textureRegion);
    void setSpeed(const Vector2f& speed);
    const Vector2f& getSpeed() const;
};

Detailed Documentation

The scroll parallax renders a TextureRegion to the screen from a position and a size specified. If the size is bigger than the TextureRegion, the TextureRegion is rendered as a repeated TextureRegion until it covers all the size of the parallax, adding movement to more than one Scroll Parallax will generate the ilusion of depth. * More info in wikipedia: http://en.wikipedia.org/wiki/Parallax_scrolling.

Construction

ScrollParallax(TextureRegion* textureRegion, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendMode::Alpha())

Constructor that create’s the Scroll Parallax

Parameters:

textureRegion

The TextureRegion to Draw

position

The position of the parallax

size

The size of the parallax

speed

Speed of movement ( in Pixels Per Second )

color

The Texture Color

Blend

The Blend Mode ( default BlendMode::Alpha())

Methods

bool create(TextureRegion* textureRegion, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendMode::Alpha())

Create’s the Scroll Parallax

Parameters:

textureRegion

The TextureRegion to Draw

position

The position of the parallax

size

The size of the parallax

speed

Speed of movement ( in Pixels Per Second )

color

The Texture Color

Blend

The Blend Mode ( default BlendMode::Alpha())

Returns:

True if success

void setColor(const Color& Color)

Set the parallax texture color.

Color getColor() const

Get the parallax texture color.

void setBlendMode(const BlendMode& Blend)

Set the Blend Mode used.

const BlendMode& getBlendMode() const

Returns:

The Blend Mode used for the parallax.

void draw()

Draw the Scroll Parallax.

void setSize(const Sizef& size)

Change the size of the current parallax

Parameters:

size

The new size

const Sizef& getSize() const

Returns:

Size

void setPosition(const Vector2f& Pos)

Change the Parallax position

Parameters:

Pos

The new parallax position

const Vector2f& getPosition() const

Returns:

The parallax position

TextureRegion* getTextureRegion() const

Returns:

The TextureRegion used for the parallax.

void setTextureRegion(TextureRegion* textureRegion)

Set Change the TextureRegion used for the parallax.

void setSpeed(const Vector2f& speed)

Set the parallax speed movement.

const Vector2f& getSpeed() const

Returns:

The parallax movement speed.