12#include "Primitives.h"
29 static std::string GetType() {
return "Sprite"; };
34 int _lastSortingLayer = 0;
66 void SetTexture(std::string path,
bool alpha = 1);
138 int Serialize(std::fstream* data,
int offset)
override;
146 int Deserialize(std::fstream* data,
int offset)
override;
Defines the GameObject class and its related components.
BatchType
Enumerates the batch types for sprites.
Definition Sprite.h:17
@ UNBATCHED
Definition Sprite.h:18
@ STATIC_BATCH
Definition Sprite.h:19
@ DYNAMIC_BATCH
Definition Sprite.h:20
Base class for game components.
Definition GameObject.h:29
Class representing a game object.
Definition GameObject.h:68
Represents an image asset.
Definition Image.h:12
The Quad class represents a quad shape.
Definition Primitives.h:56
Class representing a shader asset.
Definition Shader.h:22
Represents a game sprite.
Definition Sprite.h:26
Sprite()=default
Default constructor for the Sprite class.
double zbuffer
Definition Sprite.h:43
int sortingLayer
Definition Sprite.h:42
void StopRendering()
Stops rendering the sprite.
Definition Sprite.cpp:75
void * GetGameObject() override
Gets the GameObject that the sprite is attached to.
Definition Sprite.cpp:127
int Serialize(std::fstream *data, int offset) override
Serializes the sprite data.
Definition Sprite.cpp:85
void UnBatch()
Unbatches the sprite.
Definition Sprite.cpp:65
Quad container
Definition Sprite.h:40
void Render()
Renders the sprite.
Definition Sprite.cpp:70
void SetTexture(std::string path, bool alpha=1)
Sets the texture of the sprite from a file path.
Definition Sprite.cpp:14
~Sprite()
Destructor for the Sprite class.
Definition Sprite.cpp:131
int Deserialize(std::fstream *data, int offset) override
Deserializes the sprite data.
Definition Sprite.cpp:103
void Batch(BatchType type=BatchType::DYNAMIC_BATCH)
Batches the sprite.
Definition Sprite.cpp:59
void SetShader(std::string path)
Sets the shader of the sprite from a file path.
Definition Sprite.cpp:34
static int DefaultSpriteDrawCallback(void *data)
Default draw callback for sprites.
Definition Sprite.cpp:143
void Update() override
Updates the sprite.
Definition Sprite.cpp:79
void SetSortingLayer(int order)
Sets the sorting layer of the sprite.
Definition Sprite.cpp:48
void SetGameObject(void *go) override
Sets the GameObject that the sprite is attached to.
Definition Sprite.cpp:124
fVec3 vertexAttributes
Definition Sprite.h:38
Class representing a texture asset.
Definition Texture.h:81
Struct representing the text of a shader.
Definition Shader.h:12
Struct representing the identifier of a texture.
Definition Texture.h:12