Can anyone see why my sprites aren't working correctly?

D

Den

Guest
I have never had any issues when setting sprites before but this time around I just can't get them to show when I want them. The issue is when I move, the player object never switches to the walk cycle and even though I have an if statement to check if i'm moving horizontally or not moving on the x axis it still wont change.
I have double checked that animations by activating them in the create event for the player object and they work fine but for some reason they don't in my players move state.

Here's the code:
Code:
///scr_move_state()


    //If we're in the air apply the gravity
if (!place_meeting(x, y+1, obj_solid)) {
    vspd += grav;
    
   //Set players jump sprite
    sprite_index = spr_player_jump;
    image_speed = 0;
    image_index = (vspd > 0);
    
    
    
    //Control the jump hight
    if(jump_release_key && vspd < -6)
    {
        vspd = -1
    }
    
 
    
} else{ //<< if we're on the ground
    if(jump_key)
    {
        vspd += -16       
         //Set players ground sprites
   if (hspd == 0)
   {
    sprite_index = spr_player_idle;
   }else { //if we are moving
    sprite_index = spr_player_walk;
    image_speed = .6;
    }
  }
 }
//Move left and right
if (right_key || left_key) {
    hspd += right_key - left_key
    
  //Set the hspd's dir
  hspd_dir = right_key - left_key;
    
    //Limit the players speed
    if(hspd > spd) hspd = spd;
    if(hspd < -spd) hspd = -spd;
    

    
}else {//<< if we're not touching the R & L keys
    if (!right_key && !left_key)  {
        hspd = 0;
        
        
        
    }

}

collision_moving_scr(obj_solid);
 

obscene

Member
Use show_debug_message() or draw_text() (you can't draw here but you can set a variable to draw in the draw event) to see exactly what value hspd before trying to set the animation, the you'll know where the problem might be.
 
Top