Turon wrote:Hang on I think I'm getting somewhere I'll report back if there is any trouble.
Okay. Sorry for being so slow. :/
Turon wrote:Hang on I think I'm getting somewhere I'll report back if there is any trouble.
char *key=GetKeyState();
int playerdir=key[KEY_RIGHT]-key[KEY_LEFT];
int j=key[KEY_x];
switch(playerdir)
{
case 0: //Non or both
if(animindex==1 && jump==0)
{
ChangeAnimation("Event Actor", "PlayerStillLeft", NO_CHANGE);
}
if(animindex==2 && jump==0)
{
ChangeAnimation("Event Actor", "PlayerStillRight", NO_CHANGE);
}
if(jump==1 && animindex==3)
{
ChangeAnimation("Event Actor", "PlayerJumpLeft", NO_CHANGE);
}
if(jump==1 && animindex==4)
{
ChangeAnimation("Event Actor", "PlayerJumpRight", NO_CHANGE);
}
if(jump==0 && animindex==5)
{
ChangeAnimation("Event Actor", "PlayerStillLeft", NO_CHANGE);
}
if(jump==0 && animindex==6)
{
ChangeAnimation("Event Actor", "PlayerStillRight", NO_CHANGE);
}
break;
case -1: //Left
Collider.x-=2;
if(shootdir==1)
{
ChangeAnimation("Event Actor", "PlayerShootLeft", NO_CHANGE);
}
if(jump!=1)
{
ChangeAnimation("Event Actor", "PlayerMoveLeft", NO_CHANGE);
}
if(jump==1)
{
ChangeAnimation("Event Actor", "PlayerJumpLeft", NO_CHANGE);
}
break;
case 1: //Right
Collider.x+=2;
if(shootdir==2)
{
ChangeAnimation("Event Actor", "PlayerShootRight", NO_CHANGE);
}
if(jump!=1)
{
ChangeAnimation("Event Actor", "PlayerMoveRight", NO_CHANGE);
}
if(jump==1)
{
ChangeAnimation("Event Actor", "PlayerJumpRight", NO_CHANGE);
}
break;
}
if(Collider.yvelocity<7)
{
Collider.yvelocity+=.5;
}
CreateActor("Shot", "Shot", "(none)", "(none)", 0, 0, false);
if(shootdir==1)ChangeAnimation("Event Actor", "PlayerShootLeft", NO_CHANGE);
if(shootdir==2)ChangeAnimation("Event Actor", "PlayerShootRight", NO_CHANGE);
Turon wrote:Player > Draw Actor > Script Editor
- Code: Select all
// ...
switch(playerdir)
{
// ...
case -1: //Left
Collider.x-=2;
if(shootdir==1)
{
ChangeAnimation("Event Actor", "PlayerShootLeft", NO_CHANGE);
}
if(jump!=1)
{
ChangeAnimation("Event Actor", "PlayerMoveLeft", NO_CHANGE);
}
if(jump==1)
{
ChangeAnimation("Event Actor", "PlayerJumpLeft", NO_CHANGE);
}
break;
// ...
}
Turon wrote:Do you mean this new code is not state method? I thought the code to be much simpler and easier to understand than the last code. Bare in mind the code I displayed there was copied and pasted and the sintax may have been disturbed.
Turon wrote:I thought the code to be much simpler and easier to understand than the last code. Bare in mind the code I displayed there was copied and pasted and the sintax may have been disturbed.
Turon wrote:Do you mean this new code is not state method?
Turon wrote:But state method isn't far from what I've got here is it?
Turon wrote:Another little bug is when you jump for example right and press left in midair the player will move left but won't change animation to a jump left.
shootdir=1;
switch(playerdir)
{
case 0: // if standing right
ChangeAnimation("Event Actor", "PlayerStillLeft", FORWARD);
playerdir=1;
break;
case 1: // if standing left
ChangeAnimation("Event Actor", "PlayerMoveLeft", FORWARD);
playerdir=3;
break;
case 2: // if moving right
ChangeAnimation("Event Actor", "PlayerMoveLeft", FORWARD);
playerdir=1;
break;
case 3: // if moving left
Collider.x-=3;
break;
case 4: // or jumping right
case 5: // or jumping left
playerdir=5;
ChangeAnimation("Event Actor", "PlayerJumpLeft", FORWARD);
Collider.x-=3;
break;
}
shootdir=2;
switch(playerdir)
{
case 0: // if standing right
ChangeAnimation("Event Actor", "PlayerMoveRight", FORWARD);
playerdir=2;
break;
case 1: //if standing left
ChangeAnimation("Event Actor", "PlayerStillRight", FORWARD);
playerdir=0;
break;
case 3: // if running left
ChangeAnimation("Event Actor", "PlayerStillLeft", FORWARD);
playerdir=1;
break;
case 2: // if moving right
Collider.x+=3;
break;
case 4: // or jumping right
case 5: // or jumping left
playerdir=4;
ChangeAnimation("Event Actor", "PlayerJumpRight", FORWARD);
Collider.x+=3;
break;
}
Turon wrote:why does right have to be a even number instead of an odd one? Starting my sprite sheet with "left" makes more sense cause its like a D-pad < > but according to the wiki it has to be like this ><
Turon wrote:And why are the Animations set to "FORWARD" instead of "NO_CHANGE"?
switch(state)
{
case 0: //let's say this is is standing right state
ChangeAnimation();
state = 1; //this is move right state
break;
case 1:
x += 5;
break;
}
Hares wrote:Turon wrote:Another little bug is when you jump for example right and press left in midair the player will move left but won't change animation to a jump left.
That is because on the key down event for the left and right arrow you did not specify any animation change for the states 4 and 5.
If you use this code, then it will work:
---
Turon wrote:Hares I tried your code but it has some bugs for example if I jump left and press right in mid air (falling down) it will change animation to standing right animation.
And also if you press for example "left" and jump and while your jumping (or falling) you can jump in mid air. Maybe its because I've change the order of animations?
Users browsing this forum: No registered users and 1 guest