'Movement of character animation in java libgdx

currently I am faced with a difficulty that my character animation doesn't seem to be fluid as when I move left or right my codes seems to be rushing through the movement of the left and right animations

public Mario(World world, PlayScreen screen, int score, int lives){
        super(screen.getAtlas().findRegion("Pink_Monster"));
        this.world = world;
        currentState = State.STANDING;
        previousState = State.STANDING;
        stateTimer = 0;
        movingRight = true;

        Array<TextureRegion> frames = new Array<TextureRegion>();

//For moving left and right animations
        for (int i = 8; i < 13; i++)
            frames.add(new TextureRegion(getTexture(), i * 32, 0, 37, 40));
        PlayerRun = new Animation<TextureRegion>(0.1f,frames);
        frames.clear();
//For jumping animations
        for (int i = 1; i < 6; i++)
            frames.add(new TextureRegion(getTexture(), i * 32, 0, 37, 40));
        PlayerJump = new Animation<TextureRegion>(0.1f, frames);

        PlayerStand = new TextureRegion(getTexture(), 583, 1, 40, 40);

        controls = new Controls();

Can't seem to figure out why my jumping animation is fine no issues with that but when it moving left and right the character seems to be glitching through the sprite images that I have like lagging of sorts

This is the png I used for my character: png for character



Solution 1:[1]

If you open your image with gimp and configure the grid to be 32x40 pixels (the area that you crop) you can see that the images are not placed correctly:

enter image description here

If you created this image with a texture packing tool, there should be a .atlas file (or something similar, depending on which tool you used) that contains the correct positioning information. If you use the atlas to load the animation, you don't need to find the texture regions yourself. That makes it much easier to find the correct textures.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tobias