Alright, that's exactly what I was thinking. I just wasn't sure if the method I was using was an effective choice.
I have a resource class right now that has an inhertiable base class and is inhertied by the texture, sound and other resource classes. The SpriteAnimation class already utilizes this code to make sure that there is no duplicate textures when loading.
I have another class for static sprites, which I'm thinking of converting in to a multipurpose class for static and animated sprites.
class cSprite{protected: cGraphics* graphics; cTexture* texture; RECT pSrcRect; D3DXVECTOR2 m_view; D3DXVECTOR2 m_scale; D3DXVECTOR2 m_position; D3DXVECTOR2 m_center; float m_rotation; D3DCOLOR m_colour;public: cSprite(); ~cSprite(); bool Create(cGraphics* pGraphics, D3DXVECTOR2* pViewWindow ); void Free(); void Mask(long left, long top, long right, long bottom); void Scale(float ScaleX, float ScaleY); void Move(float PosX, float PosY); void Center(float CenterX, float CenterY); void CenterMask(); void Rotate(float radians); void Colour(uint8 Red, uint8 Green, uint8 Blue, uint8 Alpha); bool Texture(cTexture* pTexture); bool Draw(float value = 0.0f); float GetXScale(); float GetYScale(); float GetXPos(); float GetYPos(); float GetXCenter(); float GetYCenter(); float GetRotation(); DWORD GetColour();};
I'll try it and see what I get.
Quote:Original post by Kylotan
Why do you need a separate class for the loaders? I just have a Load() member function and that works ok. Sometimes it's cleaner to implement it as a static factory method but I've never felt a need to use a separate class.
The loader has all of the animation sequences and animation frames, the sprites will just have a pointer to the animation seqence so this way I can use the same sprite at different time intervals.