I have 2 sprites:
spr_t_runrightstart :
5 sub-images - loop once
used when character starts running
spr_t_runright :
6 sub-images - loop as long as shift + direction key is being held down
used when spr_t_runrightstart animation ends
I'm not sure where the error could be, so here's all the code for my controls:
if ((keyboard_check_direct(vk_right)) && (place_free(x+maxRunSpeed,y))) {
image_speed = 0.5 // Allow animations
if (keyboard_check_direct(vk_control)) { // Sneaking ?
hspeed = maxRunSpeed * 0.1 // Sneak speed : 10% of max run speed
if !(place_free(x,y+1)) { // On ground ?
sprite_index = spr_t_sneakright
} else { // In air ?
sprite_index = spr_t_jumpkickright
}
} else if (keyboard_check_direct(vk_shift)) { // Running
hspeed = maxRunSpeed // Run speed : 100%
if !(place_free(x,y+1)) { // On ground ?
if (sprite_index != spr_t_runright) { // If animation isn't spr_t_runright
sprite_index = spr_t_runrightstart // Set animation to spr_t_runrightstart
}
if (sprite_index = spr_t_runrightstart) { // If animation is spr_t_runrightstart
if (image_index = (image_number - 1)) { // And animation ended
sprite_index = spr_t_runright // Set animation to spr_t_runright
}
}
} else { // In air ?
sprite_index = spr_t_jumpright
}
} else { // Walking
hspeed = maxRunSpeed * 0.5 // Walk speed : 50% of max run speed
if !(place_free(x,y+1)) { // On ground ?
sprite_index = spr_t_walkright
} else { // In air ?
sprite_index = spr_t_jumpright
}
}
}
If you find my code to be not optimal, don't hesitate to tell me how to do it in a better way
I appreciate any help
Regards,
Jakup



Find content
Not Telling
