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
java game-physics


source to share


No one has answered this question yet

Check out similar questions:

6170
Is Java "pass-by-reference" or "pass-by-value"?
3799
How do I read / convert an InputStream to a string in Java?
3324
How to generate random integers in a specific range in Java?
3073
How to efficiently iterate over each entry in a Java map?
3044
Making a memory leak with Java
2956
What is the difference between public, secure, batch and private in Java?
2936
When to use LinkedList over ArrayList in Java?
2853
How can I convert String to int in Java?
2248
Is a finally block always executable in Java?
1367
Fastest way to determine if an integer square root is an integer



All Articles
Loading...
X
Show
Funny
Dev
Pics