GMS 2 Playing Full Animation

E

eduo

Guest
Hello guys, i'm having some trouble making the animation play fully before it stops, right now this is what i have
Code:
//Melee
if (key_melee) {
    switch(dir)    {
        case "right":
        spr_prev=sPlayerAtt;
        danoDelay = danoDelay  -1;
            if (key_melee) and (danoDelay < 0)
    {
    danoDelay = 20 ;
  
      direction = other.image_angle;
      image_angle = direction;
    image_speed = 0.5
    sprite_index= sPlayerAtt;   
    
                            
    }
    break;
    
}
}
I know it's messy, i'm trying to make it work before cleaning it up, i wanted to play a melee attack animation and have a delay before playing it again but it plays at the speed of light haha, does anyone know how to fix this? Thanks in advance!
 

obscene

Member
How are you getting key_melee?

Probably what is happening is your entire code is only running for that small moment you press the key. Instead, you need to press a key to enter a state where your player is attacking, count your timer down and then exit that state based on the timer, not the key press.
 
E

eduo

Guest
Hey, thanks for the reply! Sorry for the delay, i couldn't get to my computer, this is the code that i use to get key_melee, i'll search for the timer in the manual, and try to do that!
Code:
key_melee = keyboard_check(ord("L"));
 
Top