NWengine 0.9
|
Represents a game sprite. More...
#include <Sprite.h>
Public Member Functions | |
Sprite ()=default | |
Default constructor for the Sprite class. | |
Sprite (GameObject *go) | |
Constructor for the Sprite class. | |
~Sprite () | |
Destructor for the Sprite class. | |
void | SetTexture (std::string path, bool alpha=1) |
Sets the texture of the sprite from a file path. | |
void | SetTexture (const Image *image, TextureIdentifierPtr texId) |
Sets the texture of the sprite from an Image object. | |
void | SetTexture (Texture *tex) |
Sets the texture of the sprite. | |
void | SetShader (std::string path) |
Sets the shader of the sprite from a file path. | |
void | SetShader (const ShaderText &st, ShaderIdentifier *id) |
Sets the shader of the sprite from a ShaderText object. | |
void | SetShader (Shader *shader) |
Sets the shader of the sprite. | |
void | SetSortingLayer (int order) |
Sets the sorting layer of the sprite. | |
void | Render () |
Renders the sprite. | |
void | StopRendering () |
Stops rendering the sprite. | |
void | Batch (BatchType type=BatchType::DYNAMIC_BATCH) |
Batches the sprite. | |
void | UnBatch () |
Unbatches the sprite. | |
void | Update () override |
Updates the sprite. | |
int | Serialize (std::fstream *data, int offset) override |
Serializes the sprite data. | |
int | Deserialize (std::fstream *data, int offset) override |
Deserializes the sprite data. | |
void | SetGameObject (void *go) override |
Sets the GameObject that the sprite is attached to. | |
void * | GetGameObject () override |
Gets the GameObject that the sprite is attached to. | |
Public Member Functions inherited from GameComponent | |
virtual void | Start () |
Start the game component. | |
virtual | ~GameComponent () |
Destructor for the game component. | |
Public Member Functions inherited from Serialized | |
Serialized () | |
Default constructor for Serialized class. | |
Static Public Member Functions | |
static std::string | GetType () |
static int | DefaultSpriteDrawCallback (void *data) |
Default draw callback for sprites. | |
Static Public Member Functions inherited from GameComponent | |
static std::string | GetType () |
Get the type of the game component. | |
Public Attributes | |
TextureIdentifier | _texId {} |
Texture * | texture = nullptr |
BatchType | _isBatched = BatchType::UNBATCHED |
int | _lastSortingLayer = 0 |
bool | _shouldDraw = 1 |
bool | _isRendered = 1 |
fVec3 | vertexAttributes |
Shader * | shader = nullptr |
Quad | container |
GameObject * | attachedObj = nullptr |
int | sortingLayer = 0 |
double | zbuffer = 1.0 |
Represents a game sprite.
Represents a sprite component that can be attached to a game object.
Sprite::Sprite | ( | GameObject * | go | ) |
Constructor for the Sprite class.
go | The GameObject to attach the sprite to. |
void Sprite::Batch | ( | BatchType | type = BatchType::DYNAMIC_BATCH | ) |
Batches the sprite.
type | The batch type to use. |
Default draw callback for sprites.
data | The data to pass to the draw callback. |
Deserializes the sprite data.
data | The file stream to read the data from. |
offset | The offset in the file stream. |
Reimplemented from Serialized.
|
overridevirtual |
Gets the GameObject that the sprite is attached to.
Reimplemented from GameComponent.
Serializes the sprite data.
data | The file stream to write the data to. |
offset | The offset in the file stream. |
Reimplemented from Serialized.
Sets the GameObject that the sprite is attached to.
go | The GameObject to set. |
Reimplemented from GameComponent.
void Sprite::SetShader | ( | const ShaderText & | st, |
ShaderIdentifier * | id ) |
Sets the shader of the sprite from a ShaderText object.
st | The ShaderText object representing the shader. |
id | The identifier of the shader. |
Sets the shader of the sprite.
shader | The shader to set. |
void Sprite::SetShader | ( | std::string | path | ) |
Sets the shader of the sprite from a file path.
path | The file path of the shader. |
Sets the sorting layer of the sprite.
order | The sorting order of the sprite. |
Sets the texture of the sprite from a file path.
path | The file path of the texture. |
alpha | Flag indicating whether the texture has an alpha channel. |
Sets the texture of the sprite.
tex | The texture to set. |
|
overridevirtual |
Updates the sprite.
Reimplemented from GameComponent.
Quad Sprite::container |
Container of the sprite
int Sprite::sortingLayer = 0 |
Sorting layer of the sprite
fVec3 Sprite::vertexAttributes |
Vertex attributes of the sprite
double Sprite::zbuffer = 1.0 |
Z-buffer value of the sprite