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 / Best way to animate a series

Author
Message
chikarazuyoi
15
Years of Service
User Offline
Joined: 12th Sep 2009
Location:
Posted: 3rd Oct 2009 01:19
I need it set up so when a key press is sent such as 'Control' then a series of sprites are played related to that sprite, such as dbPlaySprite ( slash, 4, 5, 200)

i tried a for loop and while loop and i can't seem to get past sprite 4

Example:

Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 3rd Oct 2009 08:01



Not sure what you mean? that might work....
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 3rd Oct 2009 13:45 Edited at: 3rd Oct 2009 13:47
The problem is that you don't use the loop variable (i) within the loop. You execute the same instruction two times (once for i=4 and once for i=5). More exactly, I think you execute it only for 5, since you use ++i instead of i++, so the loop variable is immediately incremented.

Just to correct this, there is no need to convert the loop from "for" to "while", this change is enough:



However, be aware that dbPlaySprite does not automatically loop through all animation phases. To have the desired effect, it has to be called repeatedly every frame.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 3rd Oct 2009 13:53
P.S. Re-reading the original message, I'm not sure what you want to achieve either. Do you want to play several sprites, or just one, the one with the "splash" identifier, through all its animation phases? In any case, you need to make sure that the dbPlaySprite function is called enough times to reach the end of the animation. For example, keep calling dbPlaySprite until the current frame of the sprite, which you can query with dbSpriteFrame, reaches 200.
chikarazuyoi
15
Years of Service
User Offline
Joined: 12th Sep 2009
Location:
Posted: 3rd Oct 2009 15:56
um actually i didn't intend to use my i variable because my sprite's name is slash and those are the sprites i want to cycle the purpose of my for loop was to make sure i cycle it twice so the 2 sprites are played but the for loop does nothing
chikarazuyoi
15
Years of Service
User Offline
Joined: 12th Sep 2009
Location:
Posted: 3rd Oct 2009 16:03 Edited at: 3rd Oct 2009 16:06
okay this is my exact code



I have a sheet with over 200 sprites, i want to play sprites 22-26 in a series once the 'Return' key is pressed because i don't want to stop my slash in mid animation

Login to post a reply

Server time is: 2024-11-25 00:20:46
Your offset time is: 2024-11-25 00:20:46