Contains texture position and sub-box of all sprites for a given sprite sheet. Animations ca be handled with the following restrictions:
More...
#include <TextureAtlas.h>
|
| | TextureAtlas ()=default |
| | Build an empty atlas.
|
| | TextureAtlas (const std::string &filename) |
| | Build texture atlas from file.
|
| bool | loadFromFile (const std::string &filename) |
| | Load texture atlas from file.
|
| void | add (const std::string &entry, sf::IntRect &&textureRect, const uint32_t framesCount=1) |
| | Add a texture to the atlas.
|
| void | remove (const std::string &entry) |
| | Remove a texture from the atlas.
|
| void | clear () |
| | Clear all textures from the atlas.
|
| uint32_t | texturesCount () const |
| | Get number of textures stored in the atlas.
|
| std::optional< sf::IntRect > | textureRect (const std::string &entry, const uint32_t frame=0) const |
| | Get texture rect of an entry, if the entry exist.
|
| auto | begin () |
| auto | end () |
| auto | begin () const |
| auto | end () const |
Contains texture position and sub-box of all sprites for a given sprite sheet. Animations ca be handled with the following restrictions:
- texture rect need to represent the first frame
- all frames stand in one line on the sprite sheet
- all frames have the same size as the first one
◆ TextureAtlas() [1/2]
| sgui::TextureAtlas::TextureAtlas |
( |
| ) |
|
|
default |
◆ TextureAtlas() [2/2]
| sgui::TextureAtlas::TextureAtlas |
( |
const std::string & | filename | ) |
|
Build texture atlas from file.
- Parameters
-
| filename | File from which atlas is loaded |
◆ add()
| void sgui::TextureAtlas::add |
( |
const std::string & | entry, |
|
|
sf::IntRect && | textureRect, |
|
|
const uint32_t | framesCount = 1 ) |
Add a texture to the atlas.
- Parameters
-
| entry | Texture name |
| textureRect | Texture position and size |
| framesCount | Number of frames in the animation if needed (1 by default) |
◆ begin() [1/2]
| auto sgui::TextureAtlas::begin |
( |
| ) |
|
|
inline |
◆ begin() [2/2]
| auto sgui::TextureAtlas::begin |
( |
| ) |
const |
|
inline |
◆ clear()
| void sgui::TextureAtlas::clear |
( |
| ) |
|
Clear all textures from the atlas.
◆ end() [1/2]
| auto sgui::TextureAtlas::end |
( |
| ) |
|
|
inline |
◆ end() [2/2]
| auto sgui::TextureAtlas::end |
( |
| ) |
const |
|
inline |
◆ loadFromFile()
| bool sgui::TextureAtlas::loadFromFile |
( |
const std::string & | filename | ) |
|
Load texture atlas from file.
- Parameters
-
| filename | File from which atlas is loaded |
- Returns
- true if loading was successful
◆ remove()
| void sgui::TextureAtlas::remove |
( |
const std::string & | entry | ) |
|
Remove a texture from the atlas.
- Parameters
-
◆ textureRect()
| std::optional< sf::IntRect > sgui::TextureAtlas::textureRect |
( |
const std::string & | entry, |
|
|
const uint32_t | frame = 0 ) const |
Get texture rect of an entry, if the entry exist.
- Parameters
-
| entry | Texture name |
| frame | Texture frame it its part of an animation |
- Returns
- Texture rect if it's stored in the atlas, std::nullopt otherwise
◆ texturesCount()
| uint32_t sgui::TextureAtlas::texturesCount |
( |
| ) |
const |
|
inline |
Get number of textures stored in the atlas.
- Returns
- Number of textures stored.
The documentation for this class was generated from the following files: