19 anim->setTexture(texture);
26 anim->setSizeInSpriteMap(w, h);
33 anim->setPositionInSpriteMap(x, y);
40 anim->setFlipHorizontal(flip);
47 anim->setFlipVertical(flip);
54 anim->setAngle(angle);
109 current->setFrame(frame);
Component to handle animation of game objects. Derived from Texture.
void setRowsColsInSpriteMap(int rows, int cols)
Sets the number of rows and columns in the sprite map.
void setAnimationTime(float time)
Sets the total time for the animation cycle.
void setPositionInSpriteMap(int x, int y) override
Sets the position of the sprite in the sprite map.
bool m_isPlaying
Flag to check if the animation is currently playing.
size_t m_currentAnimation
Index of the currently active animation.
int createAnimation(SDL_Texture *texture, int rows, int cols, float time)
void setCurrentAnimation(size_t index)
void setFlipVertical(bool flip) override
Sets vertical flip status.
int getCurrentFrame() const
void setTexture(SDL_Texture *texture) override
Sets the SDL_Texture object.
size_t getCurrentAnimation() const
std::vector< Animation * > m_animations
Stores pointers to Animation objects.
void setSizeInSpriteMap(int w, int h) override
Sets the size of the sprite in the sprite map.
void setFlipHorizontal(bool flip) override
Sets horizontal flip status.
int addAnimation(Animation *animation)
void setAngle(float angle) override
Sets the rotation angle of the texture.
Animation * getCurrentAnimationObject()
GameObject * m_owner
Pointer to the GameObject that owns this component.
void setName(std::string name)
Sets the name of the component.
void setOwner(GameObject *owner)
Sets the GameObject owner of this component.
Component for handling textures in the game engine.
virtual void setTexture(SDL_Texture *texture)
Sets the SDL_Texture object.
virtual void setAngle(float angle)
Sets the rotation angle of the texture.
virtual void setPositionInSpriteMap(int x, int y)
Sets the position of the sprite in the sprite map.
virtual void setFlipHorizontal(bool flip)
Sets horizontal flip status.
virtual void setFlipVertical(bool flip)
Sets vertical flip status.
virtual void setSizeInSpriteMap(int w, int h)
Sets the size of the sprite in the sprite map.