• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [solved] Low image_speed results in wrong sprite_index??

T

trentallain

Guest
Hi, my attack animation appears to play correctly when the image_speed (normalspeed) is set to 1, but not if it is set to 0.1. So confused as to why this is happening haha.

The correct animation for the attack number is only played for 2 frames and then it switches to the attack1 animation.

statecreate is set to true when the state is changed to the attack state. Basically the "create event" for the state.

statereset works with the animation end event to reset states when the animation has ended:
Code:
if statereset == true {
    state =  shieldstate.idle;
    statereset = false;
    randomidle = irandom_range(1,3);
}
Step:
Code:
// Reset attack number
if attackresettimer > 0 {
    attackresettimer -= 1;
}
else {
    attacknumber = 1;   
}

////////////////////////////////// Finite states so other case code is irrelevant
// Attack - Can only be cancelled by rolling or getting hit
case shieldstate.attack:
if statecreate {
    hsp = attacklungespeed * directionfacing;
    image_index = 0;
    if attacknumber == 4 {
        hsp = (attacklungespeed * 1.5) * directionfacing;
        attacknumber = 1;
    }
    else {
        attacknumber += 1;
        attackresettimer = 1.2 * room_speed; // 1.2 seconds to attack without the combo ending
    }
    statecreate = false;
}
sprite_index = asset_get_index("spr_shield_attack"+string(attacknumber));   
image_speed = normalspeed;       
// Wait for the animation to end
statereset = true;
// Change states
if keyroll {
    statereset = false; // cancel whatever the attack state was doing
    state = shieldstate.roll;
    statecreate = true;
}
break;
/////////////////////////////////////
 
T

trentallain

Guest
Realised that the attackresettimer was still counting down if it was in the attack state, which means that 1.2 seconds into the animation, it will change back to the attack 1 sprite. OOPS.
 
Top