Hi, I had this problem a while a go but stopped working on the game since then and still have the same problem but I have narrowed it down further. Basically, I have programmed my game to when the player presses w it moves the sprite upwards and plays the walking up animation. The problem is it plays through all the frames in the sprite sheet. Then it gets to the ones I want it to play and plays them correctly. So it looks like my character spins around in a circle when he changes direction. Here is the code for the movement key:
while ( LoopGDK ( ) )
{
if (dbKeyState(17)==1)//UP
{
dbSetSpriteFrame(2,7);
dbPlaySprite(2,7,8,100);
cory = cory-1;
if (dbSpriteCollision(2,7)==1)
{
cory++;
}
}
if (dbKeyState(31)==1)//DOWN
{
dbSetSpriteFrame(2,1);
dbPlaySprite(2,1,2,100);
cory++;
if (dbSpriteCollision(2,6)==1)
{
cory = cory - 1;
}
}
if (dbKeyState(30)==1)//LEFT
{
dbSetSpriteFrame(2,3);
dbPlaySprite(2,3,4,100);
corx = corx-1;
if (dbSpriteCollision(2,4)==1)
{
corx++;
}
}
if (dbKeyState(32)==1)//RIGHT
{
dbSetSpriteFrame(2,5);
dbPlaySprite(2,5,6,100);
corx++;
if (dbSpriteCollision(2,5)==1)
{
corx = corx-1;
}
}
Thank-you.