spritesheet onto the screen based on what frame the animation is on. However, I have encountered a problem, and I will appreciate anyone's assistance to my problem. Happy Holidays and thanks in advance!
void Animation::PlayAnimation(int framex, int framey, int totalframes, int objectx, int objecty,BITMAP *buffer)
{
SetFrameX(framex); //Sets the X cord for SpriteSheet
SetFrameY(framey); // Sets the Y cord for SpriteSheet
SetTotalFrames(totalframes); //Total frames in animation
for(int i = 0; i < TotalFrames; i++)
{
Frame = i;
FrameX = i * Size; //Size is the size of each sprite on SpriteSheet. What this line does is sets X cord(FrameX) on the SpriteSheet to the next Sprite
if(Frame == TotalFrames) //Resets Animation when animation reaches the max frames
{
Frame = 0;
FrameX = 0;
}
}
masked_blit(SpriteSheet,buffer,FrameX,FrameY,objectx,objecty,Size,Size); //This is where i blit the sprite to the screen. But it only plays the 3(last) frame?! When I put it in the loop // it just draws all frames at the same time so it looks all like 1 bitmap
}
I have attached the SpriteSheet i am using