Java渲染bug

时间:2014-04-06 15:57:21

标签: java 2d rendering render pixel

我在java中使用一个简单的渲染方法来渲染切片。一切看起来都很好,但我注意到当我移动时,有些行增长了1个像素,然后缩小了,但我不明白为什么。信息:我使用16 x 16图块,我的渲染方法每秒运行大约500次,我使用三重缓冲,我的图块渲染方法的代码(位于Screen类中):

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];
            }
        }
    }

我从精灵表中加载精灵,它们包含数组中的像素数据

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

关于此问题的图片: http://i59.tinypic.com/330y34i.png

0 个答案:

没有答案
相关问题