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 / Delayed 2D Animation...

Author
Message
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 13th Oct 2008 02:59
The problem is, when press the Left key, the left animation starts after you are already moving. Its like this for both left and right. Its obviously cause of my inefficient code. Also if you spot any other things that could be improved, let me know.




www.Helios-Online.net
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 14th Oct 2008 17:42
No one?

...

www.Helios-Online.net
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 14th Oct 2008 19:55
I haven't responded because I don't really understand the nature of the problem. At a guess I'd say that you're changing the animation when a key is hit and you're getting a delay of some sort. It appears that before a new animation cycle can begin the old one has to expire. Based on previous threads I think the resolution was to use the dbSetSpriteFrame() function to force the frame to the first one in the new animation.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 14th Oct 2008 20:34
Ok, I tried dbSetSpriteFrame(), but the problem is, the movement is in the loop to be constantly checking so the character freezes at this frame. Although, it does fix the problem, just now the animation is frozen at the set frame.

Here is my current code for the movement.



www.Helios-Online.net
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 14th Oct 2008 22:07
I don't quite understand your logic WindowsKiller, Lilith's solution seemed to work just when you set the frame then call dbPlaySprite, it does not play the sprite, just continues to hold the animation at the set frame. The delay however is fixed.

I also can not change the delay or the animation will play too quickly.

www.Helios-Online.net
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Oct 2008 18:57
Actually there are a number of things to misunderstand about this. I'm wondering if the problem isn't that if you hold the key down in order to move in whatever direction, that you're restarting the command to play the sprite so it ends up restarting only at the first frame until you release the key.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 15th Oct 2008 22:25
Thank you Lilith lol. Ok, im going to try my best to explain the problem and what I think is going wrong.

From the source pasted above, WITHOUT dbSetFrame, the player starts moving and doesn't turn around right away. This is a 2D platformer by the way. If I do use it, the player turns just on time, but there is no walk animation, just stays at the frame called and you like slide left and right when you try to move.

I think what is happening is that the dbSetFrame is being called over and over and is stopping the animation from continuing cause this code is in the loop. So I have been trying to think of a crafty way to take this function out of the loop but still have the if statements be in check at all times. After messing around with do while loops I got no where.

I also tried WindowsKiller's suggestion by doing SOMETHING like the following but no luck at all.



www.Helios-Online.net
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Oct 2008 22:37 Edited at: 15th Oct 2008 22:37


[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Oct 2008 22:38
Quote: "I think what is happening is that the dbSetFrame is being called over and over and is stopping the animation from continuing cause this code is in the loop."


That's essentially what I was saying.

You probably need a variable to reflect which direction the player is going in.




You have to do similar code for the other directions.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 18th Oct 2008 05:01
Diggsey and Lilith's solutions haven't worked and im growing incredibly frustrated. If anyone has MSN, add me so I can send you the files.

www.Helios-Online.net
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 19th Oct 2008 17:50
this

Attachments

Login to view attachments
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 19th Oct 2008 20:01
Oh my God, THANK YOU pcRaider! That had me caught up for days. Obviously some of the other members too haha.

It works perfectly now! Time to add in my idle animations and continue on the road of 2D animation haha.

By the way, this is a sidescroller. Meaning I only needed left and right. But thanks for the example.

www.Helios-Online.net

Login to post a reply

Server time is: 2024-09-30 09:33:33
Your offset time is: 2024-09-30 09:33:33