A component that gives an entity a visual representation using a texture. More...
#include <Sprites.h>
Public Member Functions | |
| Sprites (const char *tex) | |
| Constructs a sprite from a texture path. | |
| Sprites (const char *tex, int nFrames, int mSpeed, bool loop) | |
| Constructs a sprite with simple, built-in animation capabilities. | |
| void | init () override |
| Initializes the sprite, getting the entity's transform and loading the texture. | |
| void | update () override |
| Updates the destination rectangle for rendering based on the transform. | |
| void | draw () override |
| Draws the sprite's current texture to the screen. | |
| void | recalcSpriteDimensions () |
| Recalculates the sprite's on-screen dimensions based on texture size and transform scale. | |
Public Member Functions inherited from Component | |
| virtual void | reload () |
| Called to reset the component's state. | |
Friends | |
| struct | Animator |
Additional Inherited Members | |
Public Attributes inherited from Component | |
| Entity * | entity |
| Pointer to the entity that owns this component. | |
A component that gives an entity a visual representation using a texture.
This component is responsible for drawing a texture at the entity's position. It can be controlled by an Animator component for animated sprites.
Constructs a sprite from a texture path.
| tex | The file path to the texture. |
Constructs a sprite with simple, built-in animation capabilities.
| tex | The file path to the sprite sheet. |
| nFrames | The number of frames in the animation. |
| mSpeed | The delay in milliseconds between frames. |
| loop | Whether the animation should loop. |
|
overridevirtual |
Draws the sprite's current texture to the screen.
Reimplemented from Component.
|
overridevirtual |
Initializes the sprite, getting the entity's transform and loading the texture.
Reimplemented from Component.
|
overridevirtual |
Updates the destination rectangle for rendering based on the transform.
Reimplemented from Component.