Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / 2D: Go through frames to iEnd, then loop back to iStart -- or cut straight to iStart?

Author
Message
StaticSD
14
Years of Service
User Offline
Joined: 17th Jan 2010
Location:
Posted: 18th Jan 2010 08:12
I have a basic 128x128, 16-frame player sheet. The top four frames are for the north-walking animation, the upper-middle four are for east-walking, the lower-middle are for south-walking, and the bottom four are west-walking. So, with four frames across each row:

North
East
South

West

The important parts of the code that I have are below:



For reference, the syntax for dbPlaySprite is:
( int iID, int iStart, int iEnd, int iDelay )

So, with my code, let's say I press up to walk north. Great, everything works fine. With a little extra code, not included in the snippet above, I can get the sprite to "stand still" by displaying a specific frame while no directional buttons are being pressed. No problems there. But then, after walking north, I press down to walk south. Instead of cutting to the specified iStart value of frame 9, dbPlaySprite runs through all of the frames - from whichever frame I'm at before I press down, up to the specified iEnd value of frame 12, where it will THEN loop back to frame 9.

So, in effect, if the player's sprite is facing north, and I want to walk south, it first displays the rest of the north-walking frames, then all of the east-walking frames, and then, finally, begins the south-walking animation loop.

Is there any way to skip DIRECTLY to the specified iStart frame?

neguz
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 18th Jan 2010 19:00 Edited at: 18th Jan 2010 19:02
I had the same problem, someone helped me with the problem. Here is the code. There is something extra things added but you can ignore most of it.


If thats to much extra info you dont need you basically just need



www.touchofdeathproductions.com
StaticSD
14
Years of Service
User Offline
Joined: 17th Jan 2010
Location:
Posted: 18th Jan 2010 20:51
Ahhh, of course! I was checking, outside of the checks for pressed keys, if the player's current frame was one of the four frames in his current direction, and then setting it to the first frame in the range, but that would just show that one frame only. This is much simpler, and of course works like a charm! Thanks so much!



neguz

Login to post a reply

Server time is: 2024-11-20 05:37:18
Your offset time is: 2024-11-20 05:37:18