A class used to handle the drawing and transformation of sprites.
More...
#include <Sprite.hpp>
|
void | loadFromSpriteSheet (SpriteSheet spriteSheet, size_t index) |
| Loads an image into the sprite from a spritesheet.
|
|
void | setPosition (const dl::Vector2f &position) override |
| Sets the position of the sprite.
|
|
void | move (const dl::Vector2f &offset) override |
| Moves the sprite offset number of pixels.
|
|
void | setOrigin (const dl::Vector2f &origin) |
| Sets the rotation of the sprite in radians.
|
|
void | setOrigin (float x, float y) |
| Sets the origin of the shape. The default origin is (0,0) and is the top left pixel of the shape bounds. Setting the origin can affect where the shape is drawn. For instance, setting the origin to be half the shape size will cause the shape to be centered on its position.
|
|
void | setRotation (const float &rotation) |
| Sets the rotation of the sprite.
|
|
const dl::Vector2f & | getOrigin () |
|
const float & | getRotation () |
|
void | rotate (const float &rotationOffset) |
| Rotates the sprite on top of its current rotation.
|
|
void | draw (const dl::Vector2f &viewOffset) override |
| Draws the drawable to the screen.
|
|
void | setPosition (float x, float y) |
| Sets the position of the transformable.
|
|
void | move (float xOffset, float yOffset) |
| Moves the transformable offset number of pixels.
|
|
const dl::Vector2f & | getPosition () const |
|
void | viewShouldAffect (bool effective) |
| Set whether the current view should affect the position of the drawable. Otherwise, its position on the screen will be absolute.
|
|
void | setDepth (float depth) |
| Sets the depth of the drawable for 3d. This simply corresponds to the X offset calculated for the 2 separate top screens. Larger objects will require a deeper depth for the 3d effect to be noticable. A positive value will cause the drawable to sink into the screen, while a negative value will cause it to pop out.
|
|
const float & | getDepth () const |
|
|
C2D_SpriteSheet | SpriteSheet::getSpriteSheet () |
|
|
dl::Vector2f | m_position |
|
bool | m_bViewDoesAffect = true |
|
float | m_depth = 0.0f |
|
A class used to handle the drawing and transformation of sprites.
◆ draw()
Draws the drawable to the screen.
- Parameters
-
viewOffset | The offset of the current view to be used for internal drawable positioning |
Implements dl::Drawable.
◆ getOrigin()
- Returns
- The origin in pixels
◆ getRotation()
const float & dl::Sprite::getRotation |
( |
| ) |
|
- Returns
- The sprite's rotation in radians
◆ loadFromSpriteSheet()
void dl::Sprite::loadFromSpriteSheet |
( |
SpriteSheet | spriteSheet, |
|
|
size_t | index ) |
Loads an image into the sprite from a spritesheet.
- Parameters
-
spriteSheet | The spritesheet to target |
index | The image index of the spritesheet |
◆ move()
Moves the sprite offset number of pixels.
- Parameters
-
Reimplemented from dl::Transformable.
◆ rotate()
void dl::Sprite::rotate |
( |
const float & | rotationOffset | ) |
|
Rotates the sprite on top of its current rotation.
- Parameters
-
rotationOffset | The rotation in radians to rotate |
◆ setOrigin() [1/2]
Sets the rotation of the sprite in radians.
- Parameters
-
rotation | The rotation to set (in radians) |
Sets the origin of the shape. The default origin is (0,0) and is the top left pixel of the shape bounds. Setting the origin can affect where the shape is drawn. For instance, setting the origin to be half the shape size will cause the shape to be centered on its position.
- Parameters
-
origin | The origin in pixels |
◆ setOrigin() [2/2]
void dl::Sprite::setOrigin |
( |
float | x, |
|
|
float | y ) |
Sets the origin of the shape. The default origin is (0,0) and is the top left pixel of the shape bounds. Setting the origin can affect where the shape is drawn. For instance, setting the origin to be half the shape size will cause the shape to be centered on its position.
- Parameters
-
x | The origin in pixels (X) |
y | The origin in pixels (Y) |
◆ setPosition()
void dl::Sprite::setPosition |
( |
const dl::Vector2f & | position | ) |
|
|
overridevirtual |
Sets the position of the sprite.
- Parameters
-
position | The position to set |
Reimplemented from dl::Transformable.
◆ setRotation()
void dl::Sprite::setRotation |
( |
const float & | rotation | ) |
|
Sets the rotation of the sprite.
- Parameters
-
rotation | The rotation in radians |
The documentation for this class was generated from the following files:
- include/Dualie/Graphics/Sprite.hpp
- src/Dualie/Graphics/Sprite.cpp