![]() |
Dauphine
0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
|
Visual representation of game objects. More...
#include <Sprite.h>
Public Types | |
| typedef std::shared_ptr< Sprite > | SpritePtr |
| Typedef of a Sprite shared pointer. More... | |
Public Member Functions | |
| Sprite (const std::string &path_) | |
| The constructor. More... | |
| Sprite (SDL_Surface *const surface_) | |
| ~Sprite () | |
| The destructor. More... | |
| void | render (const double x_, const double y_, SDL_Rect *const clip_=nullptr, const bool stretch_=false, const double angle_=0.0, SDL_Point *const center_=nullptr, SDL_RendererFlip flip_=SDL_FLIP_NONE) |
| Renders the sprite. More... | |
| unsigned int | getWidth () |
| void | setWidth (unsigned int width_) |
| void | setHeight (unsigned int height_) |
| unsigned int | getHeight () |
| void | setHorizontalFlip (bool isRigth_) |
| std::string | getPath () |
Private Member Functions | |
| void | loadFrom (const std::string &path_) |
| Loads image from a path. More... | |
| SDL_Texture * | surfaceToTexture (SDL_Surface *const surface_) |
Private Attributes | |
| SDL_Texture * | sdlTexture |
| The SDL texture to use as the image. More... | |
| unsigned int | width |
| The loaded image's width. More... | |
| unsigned int | height |
| The loaded image's width. More... | |
| const std::string | path |
| Holds the path from where the Sprite was loaded. More... | |
| bool | flipHorizontal |
| When true flip the image. | |
Visual representation of game objects.
Holds the SDL_Texture from the SDL2 library.
| typedef std::shared_ptr<Sprite> Sprite::SpritePtr |
Typedef of a Sprite shared pointer.
| Sprite::Sprite | ( | const std::string & | path_) |
The constructor.
Initializes all the data, and sets the desired renderer. Loads image with the desired path.
| path_ | : the image path. |
| Sprite::~Sprite | ( | ) |
The destructor.
Destroys the SDL_Texture.
| unsigned int Sprite::getHeight | ( | ) |
| unsigned int Sprite::getWidth | ( | ) |
|
private |
Loads image from a path.
Given an existing path for an image, loads the SDL_Texture from it.
| path_ | : the image path. |
| void Sprite::render | ( | const double | x_, |
| const double | y_, | ||
| SDL_Rect *const | clip_ = nullptr, |
||
| const bool | stretch_ = false, |
||
| const double | angle_ = 0.0, |
||
| SDL_Point *const | center_ = nullptr, |
||
| SDL_RendererFlip | flip_ = SDL_FLIP_NONE |
||
| ) |
Renders the sprite.
Copy the SDL_Texture onto the renderer, at the desired x,y position.
| x_ | : The position on the x axis of the screen. |
| y_ | : The position on the y axis of the screen. |
| clip_ | : Clips the texture, on the SDL_Rect bounds. If omitted, renders entire texture. |
| stretch_ | : Whether to stretch the image to the entire screen or not. |
| angle_ | : An angle in degrees that indicates the rotation that will be applied to the renderQuad. If omitted, no rotation will be applied. |
| center_ | : A point indicating the point around which renderQuad will be rotated. If omitted, rotation will be done in width/height center. |
| flip_ | : Value static which flipping actions should be performed on the texture. |
|
private |
The loaded image's width.
|
private |
Holds the path from where the Sprite was loaded.
|
private |
The SDL texture to use as the image.
|
private |
The loaded image's width.
1.8.4