Page 3 of 7

Re: Setting Animation for Actor

PostPosted: Fri Mar 21, 2014 7:12 pm
by Turon
@Harres I noticed that the ChangeAnimation actions in the collision with top side of ground event has a FORWARD animation as apposed to the norm of NO_CHANGE,
Why is that exact?

Re: Setting Animation for Actor

PostPosted: Sat Mar 22, 2014 12:19 pm
by Hares
When you add the ChangeAnimation, the default value for direction is FORWARD.
If the animation you change to only has one frame, then the direction doesn't matter. So I left it at FORWARD.
If it bothers you, you can always change it to NO_CHANGE. It will not change the way the animation appears in the game.

Re: Setting Animation for Actor

PostPosted: Sat Mar 22, 2014 2:44 pm
by Turon
oh i see! :lol: its just that I had never ever seen code submitted to the forum with Animations set FORWARD but I guess there can allways be a first time! :lol:

Re: Setting Animation for Actor

PostPosted: Tue Mar 25, 2014 11:15 am
by Turon
So the player returns to a standing position upon collision with ground, however if I were to hold down the jump button the player will jump over and over again and also without reverting to a standing position in between, I only wish for the player to jump once with one press of the button and holding it down to make no difference,
will that also require some toying with animidex?

Re: Setting Animation for Actor

PostPosted: Tue Mar 25, 2014 12:35 pm
by lcl
Turon wrote:So the player returns to a standing position upon collision with ground, however if I were to hold down the jump button the player will jump over and over again and also without reverting to a standing position in between, I only wish for the player to jump once with one press of the button and holding it down to make no difference,
will that also require some toying with animidex?

Is the collision event that sets the jump variable back to 1 set to repeat?
If that's the case, you can just check if the jump button is pressed or not, and
only let the value be set to 1 if the key is not pressed.

For checking if a certain key is pressed or not, check the GE documentation's Script Reference part and search for GetKeyState.

Re: Setting Animation for Actor

PostPosted: Tue Mar 25, 2014 5:51 pm
by Hares
lcl wrote:Is the collision event that sets the jump variable back to 1 set to repeat?

@Turon:
For now it is not set to repeat. But I don't see any reason why it could not be set to repeat.
So go ahead and set it to repeat.
lcl wrote:For checking if a certain key is pressed or not, check the GE documentation's Script Reference part and search for GetKeyState.

@Turon:
In your game, to make the players animations change in the "draw actor", the code already uses GetKeyState.
So read up on the documentation, and you should be able to figure out how to make it work in the "collision with top side of ground".

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 8:30 am
by Turon
Hares wrote:
lcl wrote:Is the collision event that sets the jump variable back to 1 set to repeat?

@Turon:
For now it is not set to repeat. But I don't see any reason why it could not be set to repeat.
So go ahead and set it to repeat.


If you mean I must set the Collision on Top side of the ground the repeat yes I've tried that and there is no visible difference as of yet.

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 8:42 am
by lcl
Turon wrote:If you mean I must set the Collision on Top side of the ground the repeat yes I've tried that and there is no visible difference as of yet.

That was only a part of it. You will also have to make sure your jumping key is not pressed before allowing the jump variable be set to 1 again. This way it won't jump again before you've released the key and pressed it again.

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 9:21 am
by Turon
This code does not work but is it moving in the right direction?
Code: Select all
char *key = GetKeyState(); //Get entire keyboard state
if(key[KEY_RIGHT] == 1) && (key[KEY_LEFT == 1)//Test if left or right key is pressed
{
jump=1;
}
if (animindex==5)
//PlayJumpLeft is animindex 5
{
    ChangeAnimation("Event Actor", "PlayerStillLeft", FORWARD);
}
if (animindex==6)
//PlayerJump is animindex 6
{
    ChangeAnimation("Event Actor", "PlayerStillRight", FORWARD);
}

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 9:44 am
by lcl
In the right direction, yes.
But two things.

First, you can't have if statements like that:
Code: Select all
if(key[KEY_RIGHT] == 1) && (key[KEY_LEFT == 1)

All the conditions must be within the same parenthesis, so that code would have to be:
Code: Select all
if((key[KEY_RIGHT] == 1) && (key[KEY_LEFT == 1))

Or you could also write it with only single big parenthesis, and I'd recommend that since it's much clearer:
Code: Select all
if(key[KEY_RIGHT] == 1 && key[KEY_LEFT == 1)


But, the actual problem with your code is that you didn't quite follow my instructions. I told you to check whether the jump key is not pressed.
Instead of doing that you checked if both the walking buttons are pressed.

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 10:33 am
by Turon
lcl wrote:In the right direction, yes.
But two things.

First, you can't have if statements like that:
Code: Select all
if(key[KEY_RIGHT] == 1) && (key[KEY_LEFT == 1)

All the conditions must be within the same parenthesis, so that code would have to be:
Code: Select all
if((key[KEY_RIGHT] == 1) && (key[KEY_LEFT == 1))

Or you could also write it with only single big parenthesis, and I'd recommend that since it's much clearer:
Code: Select all
if(key[KEY_RIGHT] == 1 && key[KEY_LEFT == 1)


I changed things according to the above. Currently the code is still unexcepted.
lcl wrote:But, the actual problem with your code is that you didn't quite follow my instructions. I told you to check whether the jump key is not pressed.
Instead of doing that you checked if both the walking buttons are pressed.

Do I just change the ones to zeros?

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 12:25 pm
by lcl
The code doesn't get accepted? What error it gives to you?

EDIT:
After taking another look at the code , there was one ] missing after the KEY_LEFT.
It was missing from your code and I just copied your code to my example and didn't notice it missing, sorry for that.
However, had you just looked at the error message GE gave, you should've been able to solve that on your own.
EDIT ENDS

Also, no, you don't change the ones to zeros. Instead you read my message properly this time.
What you should do is to check if the key for jumping is not pressed. So yes, if the state of the jumping key is 0.

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 1:07 pm
by Turon
I'd think that setting the ones to zeros would be checking that keys are not being pressed.

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 2:07 pm
by lcl
Turon wrote:I'd think that setting the ones to zeros would be checking that keys are not being pressed.

You don't say setting them to anything when you're talking about if statements, you say checking if their value is...
But besides that, yes it is, but you should check for the key that makes your character jump, not the keys for moving him horizontally.

Re: Setting Animation for Actor

PostPosted: Wed Mar 26, 2014 10:20 pm
by Turon
Oh! I get it now! The wrong keys are highlighted in my code I'll just fix that up....