Legacy GM change sprite when button is pressed

EZTALES

Member
hey yall,
so my goal today is to when you press X, your players animation changes to another sprite to do the attack animation. i also want it to work depending on which way the player is looking. here is my code below and i keep getting two issues, one the left side isn't working and second the the animation for slide will not stop once started not really sure why. any help?
Code:
//attacking right
if sprite_index = spr_player_R & keyboard_check_direct(ord("X"))
{
sprite_index = spr_player_slide_R;
}
//attacking left
if sprite_index = spr_player_L & keyboard_check_pressed(ord("X"))
{
sprite_index = spr_player_slide_L;
}
 
I think you're setting the sprite index to slide and never resetting it.

Code:
//attacking right
if sprite_index = spr_player_R & keyboard_check_direct(ord("X"))
{
sprite_index = spr_player_slide_R;
}
else
{
sprite_index = spr_player_R
}
regardless, this is a bad way to set things up. I would recommend trying a very simple state machine to control your character, it will make sure he can only be doing one thing at a time and can't get his animations and other things mixed up.
 
Top