a bug when you change arrow fast

Game Editor comments and discussion.

a bug when you change arrow fast

Postby nightFall16 » Thu Jun 23, 2016 4:45 am

the player just change the direction and not the animations .
i fixed this problem in another game demo by starting over again
without using key down action and it worked but i need to fix it here
because i did a lot of work, some one read my game code and tell
me what to change and thanks..
read the game code and show me my mistakes
Attachments
space.zip
(4.55 MiB) Downloaded 172 times
User avatar
nightFall16
 
Posts: 41
Joined: Wed Jun 22, 2016 4:24 am
Score: 2 Give a positive score

Re: a bug when you change arrow fast

Postby lcl » Fri Jun 24, 2016 12:15 pm

Hello nightFall16! Welcome to the Game Editor forum! :)

The bug you're encountering is actually not happening because of changing the direction quickly. The animations bug out because of pressing multiple keys. Let's say that you're walking right and keep the corresponding key pressed all the time. If you now press the left arrow key, the actor will stop moving, and change its animation to stopped and looking left. Now, if you still keep pressing the right arrow key and release the left arrow key, the actor will still keep the stopped and looking left animation, because the last animation change action that gets called is the one called when releasing the left arrow key. This is because you've set the running animation to start only when a key is initially pressed, so there's nothing telling it to continue the running animation after getting stopped by having two keys pressed at a time.



SOLUTION 1:
The easiest fix for this it to set your key down events for right and left arrow key (the ones that control changing animations) to repeat: yes.
Now the actor changes it's animation to the running animation every frame when the actor is actually moving. But this creates another problem: the animation resets all the time, so the only frames being shown are the first 2 frames of the running animation. But happily, there's a very simple fix for this. Adjust your ChangeAnimation()-calls to look like this:
Code: Select all
ChangeAnimation("Event Actor", "Right", NO_CHANGE);

So, change the FORWARD to NO_CHANGE. This option controls the direction in which the animation should be played. The default setting FORWARD means: "Start playing the animation from the first frame", but the NO_CHANGE setting means: "Don't change the animation direction nor reset the animation to the first frame", which allows the animation to play normally despite calling the ChangeAnimation()-function every frame.

Doing this fixes your problem.



SOLUTION 2:
Another way to solve the problem is to edit your key up events to take into account the possibility of still having some other key pressed when releasing the current key. Like this (Key Up (right)):
Code: Select all
char*key=GetKeyState();

if (cjump == 0)
{
    ChangeAnimation("Event Actor", "Jump_Right", FORWARD);
}
else if (cjump == 1)
{
    if (key[KEY_LEFT] == 1) //If the left arrow key is pressed, change to the moving left animation
    {
        ChangeAnimation("Event Actor", "Left", FORWARD);
    }
    else
    {
        ChangeAnimation("Event Actor", "Idle_Right", FORWARD);
    }
}

And then you'd of course have to make the same adjustments to the Key Up (left) event.



Both of these solutions work. But your current way of managing your animations is pretty complicated, and hard to manage and there's a high chance of new problems appearing when you try to implement new actions and animations to the actor. There's a couple of helpful articles in the Game Editor Wiki about animation handling, you may find these useful:

I hope my blabbering was of some help to you :lol: If there's something you still want to ask or something you need help with, I'll be glad to try to help you. :) P.S. Your username reminds me of my favorite band, Stratovarius
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: a bug when you change arrow fast

Postby nightFall16 » Sat Jun 25, 2016 3:51 pm

WOW man it works ...thanks man ..and most important thing to declare is YOU ARE AWESOME

i currently working in a new game with my new knowledge gathered from you and Ant bee and by the way i think i've read all of your tuts
i'am a new user it's only tow or three month studding (if we can say that haha) this program SO THANKS (sorry for bad english)
User avatar
nightFall16
 
Posts: 41
Joined: Wed Jun 22, 2016 4:24 am
Score: 2 Give a positive score

Re: a bug when you change arrow fast

Postby lcl » Sun Jun 26, 2016 10:03 am

nightFall16 wrote:WOW man it works ...thanks man ..and most important thing to declare is YOU ARE AWESOME

Haha :D I'm glad I was able to help you!

nightFall16 wrote:i currently working in a new game with my new knowledge gathered from you and Ant bee and by the way i think i've read all of your tuts
i'am a new user it's only tow or three month studding (if we can say that haha) this program SO THANKS (sorry for bad english)

Your progress with Game Editor sounds good! Good luck with your further studies of the program and most importantly, have fun creating games! :D (And don't worry about your English, this forum has users from all over the world, so only few here are actually native English speakers. Your English is fine, it gets the point accross :) )
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: a bug when you change arrow fast

Postby Zivouhr » Thu Mar 02, 2017 5:53 pm

Nice explanation for the walk animations Lcl. 8)

I like to think of the Repeat as:
Repeat Off is 1 frame, while Repeat on is every frame of the game. Similar to how the Create Actor Event only gives the command 1 time in the first frame of the affected character actor appearing, while draw actor will give the command for every frame the character appears.

With the key down walking for platformer games, there's the glitch of the "moonwalk" and how to counter it from happening, but that's for another thread of which there are a couple thankfully.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron