• 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!

Problem with x/yprevious and sprite animations?

B

BladeGamez

Guest
So I started making the sprite animations for the walking today and decided to code the actual animations in. When trying this out, everything worked except the character seemed to become a bit wider. Now it can't react to collisions as usual due to its size. The code is below



/// Switching Between animations
if (yprevious != y) {
sprite_index = robo1;
image_speed = 0;
image_index = y > yprevious;
} else {
if (xprevious != x) {
sprite_index = robo1walk;
image_speed = .3;
} else {
sprite_index = robo1;
}
}

/// Directional Animation Switch
if (xprevious < x) {
image_xscale = 1;
} else if (xprevious > x) {
image_xscale = -1;
}

Do you see any problem in the coding or would it be in the mask?
 
N

Never Mind

Guest
I bet the mask for your walking animations is bigger. I would set the objects mask to your standing sprite:
ShowMask.png
 
B

BladeGamez

Guest
I bet the mask for your walking animations is bigger. I would set the objects mask to your standing sprite:
View attachment 6791
I thought this would be the problem, too, but both sprites, including mask, are 100 x 100 pixels...



EDIT: I still need help but I seem to narrow it down. The sprite only changes when going left or right so it must either be in the controls for left or right (which I highly doubt) or it is in the code above! Any help is appreciated
 
Last edited by a moderator:
Top