At 23:33 10/03/2003, you wrote:
>Hello I am looping 24 sprite animations and for some reason they are not
>looping right. It is a sprtie
>of captin America Walking, the first 12 are him walking fowar and the
>other 12 are him walking
>backward.
I have spotted one of the problems, at least. Lets say you initially press
the 'right' key. At the end of the frame, captin.activeFrame is somewhere
between 0 and 11. If on the next frame you press the 'left' key, then
captin.activeFrame is only increased by one, making it between 1 and 12 -
i.e. it will probably still be going thrtough the 'forward' animation.
There is also an error in the 'left' section, which I have modified in the
following, denoted by '**'
So, you should modify your code like the following (lines I have inserted
are marked with '>>').
>if(!(*KEYS & KEY_RIGHT) && !(frames%5)) // if right key is pressed
>{
>> if(captin.activeFrame > 10) { captin.activeFrame = 0; }
> if(captin.activeFrame < 11)
> {
> captin.activeFrame++;
> sprites[0].attribute2 =
> captin.spriteFrame[captin.activeFrame];
> }
>
> if(captin.activeFrame == 11)
> {
> captin.activeFrame = 0;
> }
>
> if(captin.x < 220)
> {
> captin.x++;
> }
>
>
>}
>
>frames++;
>
>/*
>if(!(*KEYS & KEY_LEFT) && !(frames%5)) // if left key is pressed
>{
>> if(captin.activeFrame < 11) { captin.activeFrame = 11; }
>
> if(captin.activeFrame < 22)
> {
> captin.activeFrame++;
> sprites[0].attribute2 = captin.spriteFrame[captin.activeFrame];
> }
** if(captin.activeFrame == 22) // Was 23, but that value
could not be reached!
> {
> captin.activeFrame = 11;
> }
>
> if(captin.x > 0)
> {
> captin.x--;
> }
>}
Not sure if this is an entire solution to your problem, but I hope it helps.
Mat "ProbBob" Scales
________________________________________
Matthew Scales, mat@... / pornstar@...
http://wibbly.org.uk/~pornstar/