Animation reset

M

MUSTAFA SALAH

Guest
hey guys i have a problem i can't get the attack sprite reset to image 0 when attacking =true
it works by adding ;

else
{
if image_index != 0
{
image_index = 0;
}
}

but the other sprites stayed in image 0



my code ;
Code:
  // condition 0 (not Armed)  
    image_speed = 0.3;
    if (condition == 0)
    {
        if (grounded)
        {
            if state = adle
            {
         
            image_speed=0.3;
            sprite_index = sp_adle;
            }
            if state = run
            {
             sprite_index = sp_run
            }
        }
    }
 
    // condition 1 (Armed-sowrd)
      if (condition == 1)
    {
         if (grounded)
        {
         if state = adle
            {
             sprite_index=sp_adlesowrd;
            }
         if state = run
            {
             sprite_index = sp_runsowrd;
            }
        }
         if canattack = true
           {
       sprite_index = sp_playersowrd_attack
       } else
{
   if image_index != 0
   {
       image_index = 0;
   }
  }        
}
 

Ralucipe

Member
One thing that can help is to make sure your code is formatted and spaced consistently. If you have tabs in the right places, then it can help you more easily visualize the flow of your code:

Code:
   // condition 0 (not Armed)
   image_speed = 0.3;
   if (condition == 0)
   {
       if (grounded)
       {
           if state = adle
           {
               image_speed=0.3;
               sprite_index = sp_adle;
           }
           if state = run
           {
               sprite_index = sp_run
           }
       }
   }

   // condition 1 (Armed-sowrd)
   if (condition == 1)
   {
       if (grounded)
       {
           if state = adle
           {
               sprite_index=sp_adlesowrd;
           }
           if state = run
           {
               sprite_index = sp_runsowrd;
           }
       }
       if canattack = true
       {
           sprite_index = sp_playersowrd_attack
       }
       else
       {
           if image_index != 0
           {
               image_index = 0;
           }
       }
   }
I can't quite tell what exactly your problem is, but by looking at this formatted code I can see what conditions need to be fulfilled in order to run the block that you're having trouble with: "condition" must equal 1, and "canattack" must equal false. Based on what you said in your post, I'm guessing that this is not what you want, and that you want it to run if "canattack" equals true. So it seems like you just need to change your code up a bit to make that happen.
 
Top