Animating the entities
If you recall from previous chapters, the SpriteSheet
class we built already has great support for animations. There is no reason to annex that at this point, especially since we're only dealing with sprite-sheet based graphics. This saves us a lot of time and allows sprite-sheet animations to be handled by a single system, with no additional component overhead.
Let's start implementing the sprite sheet animation system, as always, by getting the constructor out of the way:
S_SheetAnimation::S_SheetAnimation(SystemManager* l_systemMgr) : S_Base(System::SheetAnimation,l_systemMgr) { Bitmask req; req.TurnOnBit((unsigned int)Component::SpriteSheet); req.TurnOnBit((unsigned int)Component::State); m_requiredComponents.push_back(req); m_systemManager->GetMessageHandler()-> Subscribe(EntityMessage::State_Changed,this); }
Since entity animations are, so far, entirely state-based, this system requires a state component, in addition to the sprite sheet component...