• 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 Linking separate animations

S

seventhirtysix

Guest
I've got an attack animation where I want to give a unique collision mask per frame, but I didn't find that to be possible. I found a solution here where it was suggested I break up the attacks, so I did so into three parts (pre, actual, and post).

For the object, I added an Animation End script like this:
if (sprite_index == pre) {
sprite_index = actual;
}
if (sprite_index == actual) {
sprite_index = post;
}
if (sprite_index == post) {
state = 0; //this is just a reset to idle state
}

However, this only executes the pre sprite animation, and then returns to state 0.

Am I missing a function in my blocks, or is there a better way to achieve what I want?

Thanks :)
 

Soso

Member
Hmm maybe try setting the image_index back to 0 after each sprite change.

if (sprite_index == pre) {
Image_index = 0;
sprite_index = actual;
}
 
T

tomsaram

Guest
In addition to that Soso pointed out, you should use else if to prevent skipping sprites:
Code:
if (sprite_index == pre) {
    image_index = 0;
    sprite_index = actual;
}
else if (sprite_index == actual) {
    image_index = 0;
    sprite_index = post;
}
else if (sprite_index == post) {
    state = 0; //this is just a reset to idle state
}
 
Top