GML Alternate animation not playing [SOLVED]

Discussion in 'Programming' started by OnLashoc, Aug 12, 2019.

  1. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    184
    So I have this in the Step event of my oEnemy object

    Code:
    if oEnemy.attacking == true{
    
        sprite_index = sEnemyattack;
    
    } else if oEnemy.attacking == false{
        sprite_index = sEnemy;
    }
    
    if oHero.attacking == true{
        sprite_index = sEnemyhurt;
    }
    The first line is working which is an attack animation. The second line is is working which is not an animation. The last line is working as in it is displaying the animation but only the 2nd frame. Really scratching my head here. If the code is obviously working and making it play the sEnemyhurt animation (at least it only shows the 2nd frame) then why isn't the whole animation playing?
     
  2. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    184
    The oHero.attacking is in the oHero Create event, and the oEnemy.attacking is in the oEnemy Create event.

    Once the attack button is pressed, it changes the oHero.attacking or oEnemy.attacking to true depending on who's turn it is. Again, the attacking / being attacked actions are working. The attacking animation for both the oHero & oEnemy objects are working, however sEnemyhurt and sHerohurt animations are only showing the 2nd frames and not playing their animations. The oHero code is the same as the oEnemy code except replace their names in the respective coding.
     
  3. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    184
    I fixed it, I had to swap the 2nd line for the 3rd line :D

    Code:
    if oEnemy.attacking == true{
    
        sprite_index = sEnemyattack;
    }
    
    if oHero.attacking == true{
        sprite_index = sEnemyhurt;
    }
    
    else if oEnemy.attacking == false{
        sprite_index = sEnemy;
    } 
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice