Author Topic: For Norb: Sprite Sheets...  (Read 1211 times)

matthewsjc1

  • Guest
For Norb: Sprite Sheets...
« 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!
« Last Edit: June 11, 2012, 09:21:01 pm by matthewsjc1 »