The next component that we're going to make is a
SpriteComponent. This will provide an
object with either a
static or an
animated sprite. It's a behavior that is commonly reused through many objects so is a great candidate to be moved into a component.
Currently, all the animation-related behavior is inherited from the base
Object class. The following code consists of all the sprite- and animation-related functions and variables that we'll pull from
Object into its own class:
public: virtual void Draw(sf::RenderWindow &window, float timeDelta); bool SetSprite(sf::Texture& texture, bool isSmooth, int frames = 1, int frameSpeed = 0); sf::Sprite& GetSprite(); int GetFrameCount() const; bool IsAnimated(); ...