这是最后的错误(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
吗?
关于java - 我有错误 width cannot be resolved or is not a field (It's on the render.width at the end),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20919424/