Glitch in animations,Sprites 24x21

Hello, I was recreating the Mega Man game, but I ran into a problem with the animations. For example, when I approach the edge of an element that the character jumps towards, it starts to glitch because it doesn’t know which animation to use: the jump animation or the walking animation. I want to know if this is a limitation of Mackecode or an error in my programming. I hope you can help me.
I’ve attached two photos showing the areas where the character glitches.

I’m pretty sure it’s because the sprite’s have different hitboxes, which causes the flickering.

Try to replace the hitbox with a sprite hitbox so all sprites have the same hitbox.