我有错误宽度无法解析或不是字段(它在最后的 render.width 上)



这是末尾的错误(render.width)

pixels[xPix+yPix*width] = Render.pixels [x + y * render.width]; }

这是完整的代码

package com.mime.WorldExplorer.graphics;
public class Render {
    public static int[] pixels;
    public final int width;
    public final int height;
    private int yOffset;
    private Object render;
    private int xPix;
    private int yPix;
    private int y;
    private int x;
    } 
    public void draw(Render render, int xOffset, int xoffset ) {
        for (int y = 0; y<render.height; y++); {
            int yPix = height + yOffset;
        }
    }
    {
            pixels[xPix+yPix*width] = Render.pixels [x + y * render.width]; 
    }
}

我不确定如何解决,因为我把它作为一个字段

那行代码在方法之外 - 所以render找不到。

此外,for循环声明中还有一个虚假;

for (int y = 0; y<render.height; y++);
                                     ^--- You don't want this!

目前还不清楚为什么你有这么多牙套,但我怀疑你真的想要:

// Note: I've changed the name of the third parameter from xoffset to yOffset
public void draw(Render render, int xOffset, int yOffset) {
    for (int y = 0; y < render.height; y++) {
        int yPix = height + yOffset;
        pixels[xPix + yPix * width] = Render.pixels[x + y * render.width]; 
    }
}

目前尚不清楚您期望xPix来自哪里 - 您的意思是使用xOffset吗?

相关内容

最新更新