DragonFireSDK Forum

Programming Discussions => Game Programming => Topic started by: matthewsjc1 on June 11, 2012, 09:18:40 pm

Title: For Norb: Sprite Sheets...
Post by: matthewsjc1 on June 11, 2012, 09:18:40 pm
Just do what I did and create a sprite class that handles the animation for you. As an example, here's the definition for the class I wrote and use:

class sprite_class
{
   public:
      void Create(char* imageDir, int frameCount); //Frame images should be in order, starting with "1.png".
      void Update(); //Call once in OnTimer() for each sprite.
      void SetPos(int newXPos, int newYPos);
      void SetXPos(int newXPos);
      void SetYPos(int newYPos);
      void SetToFrame(int frameNum);
      void Show(); //Makes sprite visible.
      void Hide(); //Makes sprite invisible.
      void AnimateOnce(int animationDelay); //animationDelay = ms delay between animation frames for sprite.
      void AnimateLooped(int animationDelay); //animationDelay = ms delay between animation frames for sprite.
      void StopAnimation();
      int GetNumberOfFrames();
      int GetViewId();
      int GetXPos();
      int GetYPos();
      int GetCurFrame();
      bool GetIsVisible();
      bool GetIsAnimating();
   private:
      ...
};

It'll make your life MUCH easier!