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

Legacy GM Animation bugs

I

Iniciante

Guest
Okay, I'll be straight, I'm already so stressed out. I wanted that when the enemy was walking and when it collided with a wall it would look in the opposite direction and walk until reaching another wall and repeat the process, (like a turtle in Mario for example) for the movement of the enemy is all working more the animation does not work, it only gets a solid sprite, but the impressive one (and also what's making me a little angry) is the fact that the variables and code I used for animation are not working even though I have used those same variables and codes in a prototype and worked perfectly

In the create besides the variables of hp, speed and etc have these two that are for the animation:
xPrevious = x;
yPrevious = y;


in step again has the two variables:
xPrevious = x;
yPrevious = y;

And in the end step I put this code:
if x > xPrevious{
sprite_index = spr_olho;
image_speed = 0.4;
}else if x < xPrevious{
sprite_index = spr_olho2;
image_speed = 0.4;
}

How do I solve this? (sorry my bad english)
 
R

Ratsha

Guest
If i recall correctly, you should also check if sprite index is different from what you're trying to set it to. Otherwise it will keep reusing the first image of sprite as you describe.
Code:
if x > xPrevious  && sprite_index != spr_olho {
   sprite_index = spr_olho;
   image_speed = 0.4;
} else if x < xPrevious && sprite_index != spr_olho2 {
   sprite_index = spr_olho2;
   image_speed = 0.4;
}
Please tell me if it works.
 

TheouAegis

Member
FYI xprevious and yprevious are built-in variables that already do the same thing as your xPrevious and yPrevious variables.

Also make sure if you decide to use your own variables still, that you set them at the beginning of the step event, not at the end.
 
Top