• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Animation transitioning (Need Help!)

V

Valcia

Guest
Ive been trying to make my player from idle to attack animation when he is grounded and when he press the L key but it just wont work since my idle is overwriting it?
Here is my code
<
_keyL = keyboard_check_pressed(ord("L"));
_keyD = keyboard_check(ord("D"));
_keyA = keyboard_check(ord("A"));
_keySpace = keyboard_check_pressed(vk_space);

//grounded check
if(vspeed > 0){_grounded = true;}

//run right
if (_keyD == true && hspeed > 0)
{
_run = true;
image_speed = 0.7;
sprite_index = spr_shield_run_right;
}
//run left
if (_keyA == true && hspeed < 0)
{
_run = true;
image_speed = 0.7;
sprite_index = spr_shield_run_left;
}
//jump right
if (_keySpace == true)
{
_run = false;
_jump = true;
_grounded = false;
image_speed = 0.3;
sprite_index = spr_shield_jumping_right;
}

//grounded
if ( vspeed == 0 && hspeed == 0)
{
_attacks = 4;
_attack = true;
_run = false;
_jump = false;
_grounded = true;
_idle = true;
image_speed = 0.3;
sprite_index = spr_shield_idle;

}
//if player not grounded n jump Right
if (hspeed > 0 and vspeed < -1)
{
sprite_index = spr_shield_jumping_right;
}
//if player not grounded n jump Left
if (hspeed < 0 and vspeed < -1)
{
sprite_index = spr_shield_jumping_left;
}
//if running and L press
if( mouse_check_button_pressed(mb_left))
{
image_speed = 0.1;
sprite_index = spr_shield_combo1_R;
_idle = false;
_attack = true;
_attacks = _attacks - 1;
}

/>
 

woods

Member
Code:
if(vspeed > 0){_grounded = true;} 


if ( vspeed == 0 && hspeed == 0)
{ 
...  
_idle = true;
...
}



if( mouse_check_button_pressed(mb_left))
{
...
_idle = false;
...
}

couple of thoughts here.. might aim in the right direction ;o) considering my lack of experience...

as long as you are not moving, _idle is true
mb_left clicked sets _idle to false

so if you click, it sets false and then immediately sets to true again because of no speed?




mouse_check_button_pressed(mb_left) only checks once for a press.. maybe you want the button held down? mouse_check_button(mb_left)
 

Nidoking

Member
You're setting _keyL when you detect an L press. Your attack state triggers on mouse_check_button_pressed(mb_left). I have no idea why you expected one of these things to affect the other, but they won't.
 
V

Valcia

Guest
Code:
if(vspeed > 0){_grounded = true;}


if ( vspeed == 0 && hspeed == 0)
{
... 
_idle = true;
...
}



if( mouse_check_button_pressed(mb_left))
{
...
_idle = false;
...
}

couple of thoughts here.. might aim in the right direction ;o) considering my lack of experience...

as long as you are not moving, _idle is true
mb_left clicked sets _idle to false

so if you click, it sets false and then immediately sets to true again because of no speed?




mouse_check_button_pressed(mb_left) only checks once for a press.. maybe you want the button held down? mouse_check_button(mb_left)
yes i understand wht ur trying to say and thx for the reply ! :D. Sorry for the keyL thing, it is not related. But anyway, i dont want the player hold down to be able to spam the button since it will be overpowered.
 

Nidoking

Member
You must surely want some other condition in addition to not moving to begin the idle state. Especially since that state seems to be both idle AND attack. That can't be right - you're starting the attack every time the player isn't moving? You're starting the attack EVERY STEP every time the player isn't moving. But using the idle animation.
 
Top