r/gamemaker • • Jun 06 '14

Help! (GML) Attacking Animations Help [GML]

I'm currently using version 1.3.1344 and I have been trying to get this to work. Basically I want to have my object (and not my player, right now I'm having my weapon obj float in the air) have multiple combos. So attack once and if you attack again right afterwords then it plays out a new animation and same for the third time. If you attack again too late, then it simply starts over.

Attacking Code

You can ignore the first four variables. Does anyone know what I'm doing wrong? I tried adding in release keyboard code but in the end that only changed the sprite when pressing the attack button and changed it back when releasing, it ignored the timers. You can also ignore which animations I picked, I was just going on random.

5 Upvotes

34 comments sorted by

View all comments

Show parent comment

1

u/ZeCatox Jun 09 '14

you can also place the "alarm[N] = ... " along with each line where you do "sprite_index = ...". This way you could set a custom timing for each sprite.

// ...
if can_attack and keyboard_check_pressed (ord('X'))
{
    Key_Attack = true;
    can_attack = false;
}
// ...

if (Key_Attack) && (Attack2 = false) && (Attack3 = false)
{
    Attack2 = true;
    sprite_index = player_djump;
    alarm[N] = delay_1;
    if alarm[0]=-1 alarm = 50;  // those lines still look wrong ;)
}
    else
    {
        if (Key_Attack) && (Attack2 = true)
        {
            Attack2 = false;
            Attack3 = true;
            image_index = 0;
            sprite_index = player_idle;
            alarm[N] = delay_3;
            image_speed = 0.125
            if alarm[1]=-1 alarm = 50;  // those lines still look wrong ;)
        }
    else
    {
        if (Key_Attack) && (Attack3 = true)
        {
        Attack3 = false;
        image_index = 0;
        sprite_index = player_slash;
        alarm[N] = delay_3;
        image_speed = 0.125
        if alarm[2]=-1 alarm = 100;  // those lines still look wrong ;)
        }
    }
}

1

u/1magus Jun 09 '14

You can call them wrong all you wish, but without the if statement and the negative part, they don't work right.

1

u/1magus Jun 09 '14

Also I can't fully understand how to program in the delay right now, see my code below. So I can't figure out how to do a delay for sprite_index

1

u/1magus Jun 09 '14

I must be losing my mind, I put and instead of &&. Anyway the code still bugs out switching the animation. I can't figure out why.

1

u/1magus Jun 09 '14

I didn't even notice your code from above, let me go and try that. It does seem much simpler than what I had.