Java 2D game animation issue

I am working on a swimming animation. When the player collides with waterTile

, the float animation does not play when the player goes left (lt), and when the player goes right (rt), the up animation plays.

Here is the Render method from Player.java

: -EDITED -

if (isSwimming){
        if (up) {
            swimUp.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        } 
        if (dn){
            swimDown.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        }
        if (rt){
            swimRight.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        }
        if (lt){
            swimLeft.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        }
    }       
 if (!isSwimming){
        if(up){
            upAnimation.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        } 
        if (dn){
            downAnimation.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        }
        if (rt){
            rightAnimation.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        }
        if (lt){
            leftAnimation.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);
        } else
            idle.render(g, x, y, Game.TILESIZE * Game.SCALE, Game.TILESIZE * Game.SCALE);

}

      

Also, it might be worth noting that no errors are displayed.

+3


source to share





All Articles