我正在制作一个游泳动画。当玩家与waterTile
发生碰撞时,当玩家离开(lt)时游戏动画不会播放,当玩家向右移动(rt)时,游戏动画会播放。
以下是Player.java
的Render方法:
-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);
}
此外,值得注意的是,没有显示错误。