Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Sprite Looping Back Then Fowrard   Message List  
Reply | Forward Message #13811 of 15019 |
Re: [gbadev] Sprite Looping Back Then Fowrard

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/





Tue Mar 11, 2003 5:20 pm

mscales@...
Send Email Send Email

Forward
Message #13811 of 15019 |
Expand Messages Author Sort by Date

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...
JC Matthews
kreedskulls
Offline Send Email
Mar 11, 2003
9:59 am

Hello, Don't know quite what you were trying to do but I hope this helps some. // frames 0-11 = walk RIGHT // frames 12-23 = walk LEFT if (RIGHT key pressed) {...
Martin Gibbins
gibbsteruk
Offline Send Email
Mar 12, 2003
9:24 am

... 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 ...
Mat Scales
mscales@...
Send Email
Mar 12, 2003
9:25 am

you forgot the conditions press right (having been going left) so captin.activeFrame > 11 ... From: "JC Matthews" <kreedskulls@...> To:...
Mike Wynn
mike.wynn@...
Send Email
Mar 12, 2003
9:25 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help