Setting Animation for Actor(Experimenting with State Method)

Non-platform specific questions.

Re: Setting Animation for Actor

Postby Turon » Fri Mar 21, 2014 7:12 pm

@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?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Hares » Sat Mar 22, 2014 12:19 pm

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.
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Sat Mar 22, 2014 2:44 pm

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:
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Tue Mar 25, 2014 11:15 am

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?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Tue Mar 25, 2014 12:35 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Setting Animation for Actor

Postby Hares » Tue Mar 25, 2014 5:51 pm

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".
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Wed Mar 26, 2014 8:30 am

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.
Last edited by Turon on Wed Mar 26, 2014 10:52 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Wed Mar 26, 2014 8:42 am

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Wed Mar 26, 2014 9:21 am

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);
}
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Wed Mar 26, 2014 9:44 am

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Wed Mar 26, 2014 10:33 am

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?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Wed Mar 26, 2014 12:25 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Wed Mar 26, 2014 1:07 pm

I'd think that setting the ones to zeros would be checking that keys are not being pressed.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Wed Mar 26, 2014 2:07 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Wed Mar 26, 2014 10:20 pm

Oh! I get it now! The wrong keys are highlighted in my code I'll just fix that up....
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron