Java渲染错误

Java渲染错误,java,2d,rendering,render,pixel,Java,2d,Rendering,Render,Pixel,我正在使用java中的一种简单的渲染方法来渲染平铺。一切看起来都很好,但我注意到有些行在移动时会增长1像素,然后又收缩,但我不知道为什么。Infos:我使用的是16 x 16平铺,我的渲染方法每秒运行500次,我使用三重缓冲,这是我的平铺渲染方法的代码(位于Screen类中): public void renderTile(int-xPos、int-yPos、Tile-Tile){ xPos-=xOffset; yPos-=约夫特; 对于(int y=0;y

我正在使用java中的一种简单的渲染方法来渲染平铺。一切看起来都很好,但我注意到有些行在移动时会增长1像素,然后又收缩,但我不知道为什么。Infos:我使用的是16 x 16平铺,我的渲染方法每秒运行500次,我使用三重缓冲,这是我的平铺渲染方法的代码(位于Screen类中):

public void renderTile(int-xPos、int-yPos、Tile-Tile){
xPos-=xOffset;
yPos-=约夫特;
对于(int y=0;y<16;y++){
int-yPixel=y+yPos;
对于(int x=0;x<16;x++){
int xPixel=x+xPos;
如果(yPixel<0 | | yPixel>=高度)继续;
如果(xPixel<0 | | xPixel>=宽度)继续;
像素[(xPixel)+(yPixel)*宽度]=tile.sprite.pixels[x+y*tile.sprite.size];
}
}
}
我从精灵工作表加载精灵,它们在数组中包含像素数据

有人能帮忙吗?(如果需要任何其他信息,请告诉我)

有关该问题的图片:

public void renderTile(int xPos, int yPos, Tile tile) {
        xPos -= xOffset;
        yPos -= yOffset;

        for (int y = 0; y < 16; y++) {

            int yPixel = y + yPos;

            for (int x = 0; x < 16; x++) {
                int xPixel = x + xPos;
                if (yPixel < 0 || yPixel >= height) continue;
                if (xPixel < 0 || xPixel >= width) continue;
                pixels[(xPixel) + (yPixel) * width] = tile.sprite.pixels[x + y * tile.sprite.size];
            }
        }
    }