SOLVED Multiple Jumping Animations

ZaPowar

Member
Hello there fellow programmers,
I have a problem concerning the code that affects the jumping animation of my player in a 2D Platformer.
What I want to happen is when the jump button is pressed and the player is on ground I want spr_Player_Jump to play once.
Then when the player is the air before arriving at the peak of his jump spr_Player_InAir will play.
Every time the player is falling, spr_Player_Falling will play.
Every time the player touches the ground after a jump or a chute spr_Player_FaillingStop will play once.
This is the code:

GML:
//Get Player Input
key_jump = keyboard_check_pressed(vk_space);

//See if the character touches the ground
if (place_meeting(x,y+1,obj_Wall)) {
    grounded = true;
} else {
    grounded = false;
}

//Jumping
if(grounded) and (key_jump){
        vsp = -7;       
}


//Animation
if(!grounded){
    sprite_index = spr_Player_Jump;
    if(sign(vsp)>0) sprite_index = spr_Player_Falliing; else sprite_index = spr_Player_InAir;
}else{
    if(grounded) and (sprite_index = spr_Player_Falliing){
        sprite_index = spr_Player_FalliingStop;
    }else{
    if(hsp == 0){
        sprite_index = spr_Player_Idle;
    }else{
        sprite_index = spr_Player_Wabble;
    }
    }
}
Thank you for taking the time to respond to my Post.
 
Top