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 / Simple Movement

Author
Message
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 21st Jun 2009 08:32
Hello, i created some simple movement code. I know this is probably extremely bad code, but im just learning c++ so bear with me.



It is hard to explain the problem. Basically the movement works fine, but i believe that when i stop pressing a direction the commands stop before the animation is fully finished. When i start walking in a new direction it starts playing the frames left over from the last direction and messes up my movement. I think that is what happening im not sure. Again very hard to explain. This youtube video shows the bug im getting. I hope someone can provide me with some help or code.

Thanks in advance.


http://www.youtube.com/watch?v=a8NQV8FZmhU
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 21st Jun 2009 12:09
There was another thread with a similar problem recently but I can't find it now. Anyway, the solution is that when the direction of the sprite changes, you need to call dbSetSpriteFrame to set the beginning frame of the new animation. Something like this:



Not tested but it should work. Let me know if it doesn't.

Also, the dbSprite command seems to be the same in all the "if" cases. You can try to place that command after the "if" selections, only once.
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 22nd Jun 2009 06:45
I tried that before you asked but with a different frame. I also tried yours it does not work. Any other ideas?


Thank you.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 22nd Jun 2009 21:22 Edited at: 22nd Jun 2009 21:24
For testing, I have created a sprite with 16 animation frames (4 in each direction). Then I tried this code, corresponding to my suggestion above:



It works fine. As soon as a different direction key is pressed, the animation changes without leftover frames.
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 22nd Jun 2009 21:28
Ah, i am not sure what i did wrong then, i just put in your code and it works beautifully. I think my problem may have been i was using the last frame instead of the first.

Anyway, thank you very much it works great.

Login to post a reply

Server time is: 2024-10-01 06:04:31
Your offset time is: 2024-10-01 06:04:31