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

Jump Sprites

C

ChrisMG12

Guest
I have made my sprites for moving left and right and idle position work without any glitches. however whenever i jump the same sprites for being idle and moving left and right occur, is there any code that can help me with this. the code is from this video,
.
i also added this code for the sprites for the sprite change in idle (l and r) and moving (l and r)(with help from CloseRange)
dir = sign(x - xprevious);
if dir != 0 last_dir = dir;
if (dir == 1)
{
sprite_index = spr_character_running_right; // RIGHT MOVING SPRITE
}
if (dir == -1)
{
sprite_index = spr_character_running_left; // LEFT MOVING SPRITE
}
if (dir == 0) {
if (last_dir == 1)
{
sprite_index = spr_character_facingright; // RIGHT IDLE SPRITE
}
if (last_dir == -1) {
sprite_index = spr_character_facingleft; // LEFTIDLE SPRITE
}
}
 
C

ChrisMG12

Guest
there is a L and R sprite for both idle and moving in jumping.
 

Simon Gust

Member
You need a way to check if your object is standing on the ground or not.
Code:
on_the_ground = place_meeting(x, y+1, obj_wall);
similar like you do when you check if you can jump.

in your animations, check for both being on the ground and not being on the ground, creating a sort of twin if structure
Code:
if (on_the_ground) // or just if (place_meeting(x, y+1, obj_wall))
{
    // your code you have above
}
else
{
    // your code you have above except sprites are exchanged by the other sprites for jumping and idling / running
}
 
C

ChrisMG12

Guest
thanks i will try this out, i will inform if it works. Thanks
 
C

ChrisMG12

Guest
You need a way to check if your object is standing on the ground or not.
Code:
on_the_ground = place_meeting(x, y+1, obj_wall);
similar like you do when you check if you can jump.

in your animations, check for both being on the ground and not being on the ground, creating a sort of twin if structure
Code:
if (on_the_ground) // or just if (place_meeting(x, y+1, obj_wall))
{
    // your code you have above
}
else
{
    // your code you have above except sprites are exchanged by the other sprites for jumping and idling / running
}
Thank you so much, it works really well.
 
Top