How Do you Execute MOve and Return to standby Images?

Non-platform specific questions.

How Do you Execute MOve and Return to standby Images?

Postby ggesterGamePro99 » Mon Apr 16, 2012 3:40 pm

In Event Add/Key Down/ I add a Chang Animation move. So that it switches to some move.
for example a punch. after i release i expect it to go back to the standby animation which is just standing and breathing.

So i thought i set it to return to the STANDBY Images in the Even Add/Key up/ and so i did that and i said Repeat DISABLED thinking that it will just do the animation once after pressed and release key. But it doesn't do that, what it does is, i press the key and release it and it keeps looping the punch(or whatever) animation. this is weird.

So how do you do it?

But it's not good to do it in EvenAdd/Key up/Change animation to Standbyimage, because i want the standbyimages to be LEFT or RIGHT depending on which side you are facing, but with Change animation you only select one set of animations...

SO I NEED TO instead add the punch and return to standby images into the script which I use for the LEFT AND RIGHT walking.

I have that in EVENT ADD/DRAWACTOR/SCRIPT
char *key = GetKeyState();
int dir = key[KEY_RIGHT] - key[KEY_LEFT];

switch( dir)
{
case 0 : //None or Both
if( animindex == 0)
{
//Change to standby images
ChangeAnimation( "Event Actor", "StandbyLeft", NO_CHANGE);
}
else if( animindex == 1)
{
//Change to standby images
ChangeAnimation( "Event Actor", "StandbyRight", NO_CHANGE);
}
break;

case -1: //LEFT
x -=5;
ChangeAnimation( "Event Actor","Left", NO_CHANGE);
break;

case 1 : //RIGHT
x +=5;
ChangeAnimation( "Event Actor", "Right", NO_CHANGE);
break;
}


*******
Where in this script do i add the code for responding to user clicking and releasing keys and
make it be so that the animation runs and once it ends it goes back to the appropriate(left or right) standby images depending on which side character is facing?

Before i tried doing putting this after the Swticth statement above, but it didn't work:

if( key[KEY_c]==1){
ChangeAnimation( "Even Actor", "Punch", NO_CHANGE);
if( key[KEY_c} == 0){ //CHANGE BACK TO Approrpriate facing standby animations
if( animindex == 0 )
ChangeAnimation( Even Actor, STANDBYLEFTT, NO CHANGE)
if( animindiex == 1)
ChangeAnimation( Even Actor, STANDBYRIGHT, NO CHANGE)
}

I mean, this did work in Responding to me pressing THE C key.
But once i pressed and released the key once, it kept looping the animation unless i click the arrow keys to move, then it would stop
How do i fix it so that, i press and relase the C key and it executes the animation only once, and then goes back to standbyright or standbyleft
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby ggesterGamePro99 » Mon Apr 16, 2012 4:23 pm

Also With this code after the ARROW KEYS CODe:
if( key[KEY_c]==1){
ChangeAnimation( "Even Actor", "Punch", NO_CHANGE);
if( key[KEY_c} == 0){ //CHANGE BACK TO Approrpriate facing standby animations
if( animindex == 0 )
ChangeAnimation( Even Actor, STANDBYLEFTT, NO CHANGE)
if( animindiex == 1)
ChangeAnimation( Even Actor, STANDBYRIGHT, NO CHANGE)
}


What happened is when i pressed the arrows it would not switch to the walking images anymore. It would remain in the standby animation just standing and it looked like it was sliding. Kinda funny.

anyway, I know i'm confusing but my basic question is

if i have the above code for the arrow keys movement, where do i insert the code for checking press and release of single keys for single moves( punch, kick, etc)
and what exactly should the code be to do a move only once and return to the approrpriate standby animation.
As i said before, i've tried swtiching back to the standby anims using key up event and even Animation finish event, but it just doesn't work.
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby skydereign » Mon Apr 16, 2012 4:23 pm

I don't suggest you do it that way. Since you say you just started gE, it is best to learn how the event structure works. So you shouldn't be using the draw event to replace the keydown events. But, it does seem you know about variables, so this'll be a little easier.

The right/left buttons are used to change dir. I use dir=0 for right, and dir=1 for left. I'll assume you already have that setup.

Now you have your attack button key event, which changes the player's animation to attack right or attack left, depending on dir.
Code: Select all
switch(dir)
{
    case 0: // right
    //ChangeAnimation to attack right goes here
    break;

    case 1: // left
    //ChangeAnimation to attack left goes here
    break;
}

If you want it to change the animations back on keyup, then you can do the same code (but change the animation to standing animations instead of attacking). Or, you can not use a keyup event, and use animation finish events to reset it back to standing events.
player -> Animation Finish (attack_right) -> Script Editor
Code: Select all
ChangeAnimation("Event Actor", "stand_right", FORWARD);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby ggesterGamePro99 » Mon Apr 16, 2012 4:31 pm

I guess i know what the problem is with my last part of the code is


First insstead of IF( KEY c == 0) i should use some kind of code( which i dont' know) which tests if c was just released. Is there such a code?

And i know my problem
I said IF ( KEY C == 1 ) then do this
IF( KEY C ==0 ) then do that.


And even if i press the arrow keys, key C is gonna be 0..so that's why i was getting STANDBY animations even with pressing the arrow keys...
So like i said
i need to do something like
IF( KEY C == 1 ) execute punch
else if ( key C was just released) go back to standbyimages depending on which side character is facing.

mmm..Anyone know how to do that?
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby ggesterGamePro99 » Mon Apr 16, 2012 4:34 pm

skydereign wrote:I don't suggest you do it that way. Since you say you just started gE, it is best to learn how the event structure works. So you shouldn't be using the draw event to replace the keydown events. But, it does seem you know about variables, so this'll be a little easier.

The right/left buttons are used to change dir. I use dir=0 for right, and dir=1 for left. I'll assume you already have that setup.

Now you have your attack button key event, which changes the player's animation to attack right or attack left, depending on dir.
Code: Select all
switch(dir)
{
    case 0: // right
    //ChangeAnimation to attack right goes here
    break;

    case 1: // left
    //ChangeAnimation to attack left goes here
    break;
}

If you want it to change the animations back on keyup, then you can do the same code (but change the animation to standing animations instead of attacking). Or, you can not use a keyup event, and use animation finish events to reset it back to standing events.
player -> Animation Finish (attack_right) -> Script Editor
Code: Select all
ChangeAnimation("Event Actor", "stand_right", FORWARD);


Awesome. I'll study what you wrote and try it out.
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby ggesterGamePro99 » Mon Apr 16, 2012 5:15 pm

Hey skydereign

So now i got it to work with Keydown and keyup. i added the switch ( dir) block to each.

Now it works but, when i press the attack key. it goes to the first frame of the attack animation.. and i release and then it goes back to the standby animation.
If i press and hold.. it stays in the same frame 1 of the attack animation until i release.

But why doesn't it go through the complete animation. why just the first frame. ?
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby skydereign » Mon Apr 16, 2012 5:20 pm

That is because you set the animation to repeat. There are two ways of fixing this. The first way is just to disable the keydown event from repeating (I suggest this one). The other way is to not change the animation's direction (changing FORWARD to NO_CHANGE). The reason the first method is better is it makes sense according to what you want. The event you want isn't the key being pressed, all you really want is the keydown event when it happens. If for instance you were doing movement in that event, you would want the event to trigger every frame the key is pressed, but if you just want to change animation the first frame the key is pressed, then you would want repeat set to disable.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby ggesterGamePro99 » Mon Apr 16, 2012 5:26 pm

skydereign wrote:That is because you set the animation to repeat. There are two ways of fixing this. The first way is just to disable the keydown event from repeating (I suggest this one). The other way is to not change the animation's direction (changing FORWARD to NO_CHANGE). The reason the first method is better is it makes sense according to what you want. The event you want isn't the key being pressed, all you really want is the keydown event when it happens. If for instance you were doing movement in that event, you would want the event to trigger every frame the key is pressed, but if you just want to change animation the first frame the key is pressed, then you would want repeat set to disable.



Thanks. I'll try that.
Another thing i did is instead of KeyUp, i did Animation Fisnish. and that made it work. It went throught the attack animation and then it went back to the standbyimages.

So is it better to do Event Animation Finish or use the Key up?
I'll try what you said though
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: How Do you Execute MOve and Return to standby Images?

Postby skydereign » Mon Apr 16, 2012 5:32 pm

ggesterGamePro99 wrote:So is it better to do Event Animation Finish or use the Key up?

gameEditor provides a lot of events so you can make that decision. You are the one making the game, so you should know which event is best to use in whatever case. If in your game you want the player to go back to standing when you release the attack key, then of course it would make sense that using the keyup event would be better. But, if you want the player to move through the entire animation before resetting to the stand animation, you would need to use an animation finish event. You can probably tell that those two events actually do very different things, and whichever you choose is your preference. As for my personal preference, I would go with the animation finish version (since I don't like being able to escape out of my attack animation before I finish the attack [most games don't allow you to do that]).

As I mentioned before, it is very important to learn the event structure gameEditor uses. If you can understand that, then making games in gE will be a lot easier for you.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron