Reversing animated sprites

Posted by brandon sedgwick on Game Development See other posts from Game Development or by brandon sedgwick
Published on 2013-10-24T10:11:17Z Indexed on 2013/10/24 10:15 UTC
Read the original article Hit count: 183

Filed under:
|

I have created a sprite sheet of which consists of 6 frames with a character moving legs each frame, now I have coded it so that the animation is running successfully from frame 1 to 6, however I am trying to reverse this so then when it goes from 1 to 6 instead of restarting it go's 6 to 1 in a continuous loop. The coding for current animation is:

void SpriteGame::Update(int tickTotal, int tickDelta)
{
//This is where you manage the state of game objects 
if ( tickTotal >= this->playerLastFrameChange + 4)
{
//Four ticks have elapsed since the last frame change
this->playerFrame = this->playerFrame + 1;
this->playerLastFrameChange = tickTotal;  //We've just changed the frame 

if (this->playerFrame >= this->playerSheetLength)
{
    this->playerFrame = playerLastFrameChange + 4;
}

//Frame has changed so change the source rectangle
this->playerSourceRect->left = this->playerFrame * 64;    
this->playerSourceRect->top = 0;     
this->playerSourceRect->right = (this->playerFrame + 1) * 64;  
this->playerSourceRect->bottom = 64; 
}
}

any help please I am using DirectX11 as thats what we are being told to use as its for an win 8 game.

© Game Development or respective owner

Related posts about c++

Related posts about directx11