A
Agletsio
Guest
Trying to add jump animation to Player. My approach at the moment is to say that whenever the Player is not touching the floor(obj_wall), play the jump sprite (basically whenever the character is in mid-air) and vice versa.
Below is my current code setup (only the //Sprite Control section in Player step event, let me know if you want to see full code). With this code, the player just stays in jump sprite (when the game starts, he falls he a bit before touching ground). So controls and everything working normally except for playing the right sprite.
Am i approaching this in the wrong way? Any help or guidance will be appreciated!
//Sprite Control
if !place_meeting(x,y,obj_wall) {
sprite_index = Player_jump
}
else
if !place_meeting(x,y,obj_wall) {
if keyboard_check (vk_left)
{
sprite_index = walk_left;
}
if keyboard_check (vk_right)
{
sprite_index = walk_right;
}
if !keyboard_check (vk_left) && !keyboard_check (vk_right)
{
if sprite_index == walk_right sprite_index = idle_right;
else if sprite_index == walk_left sprite_index = idle_left;
}
}
Below is my current code setup (only the //Sprite Control section in Player step event, let me know if you want to see full code). With this code, the player just stays in jump sprite (when the game starts, he falls he a bit before touching ground). So controls and everything working normally except for playing the right sprite.
Am i approaching this in the wrong way? Any help or guidance will be appreciated!
//Sprite Control
if !place_meeting(x,y,obj_wall) {
sprite_index = Player_jump
}
else
if !place_meeting(x,y,obj_wall) {
if keyboard_check (vk_left)
{
sprite_index = walk_left;
}
if keyboard_check (vk_right)
{
sprite_index = walk_right;
}
if !keyboard_check (vk_left) && !keyboard_check (vk_right)
{
if sprite_index == walk_right sprite_index = idle_right;
else if sprite_index == walk_left sprite_index = idle_left;
}
}