[英]Compiling Error: Not a Statement
我正在研究基於文本的RPG,並且在處理它時遇到了此錯誤。
package game;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
/**
*
* @author Pyro
*/
public class SpriteSheetLoader {
public int[] sheetPixels;
public int[] pixels;
int x, y, sheetWidth;
public SpriteSheetLoader(BufferedImage sheet){
BufferedImage image = new BufferedImage(sheet.getWidth(), sheet.getHeight(), BufferedImage.TYPE_INT_ARGB);
image.getGraphics().drawImage(sheet, 0, 0, null);
sheetPixels = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();
sheetWidth = sheet.getWidth();
}
public void grabTile(int tile, int width, int height) {
sheetPixels = new int[width * height];
int xTile = tile % 16;
int yTile = tile % 16;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int value = pixels[(x + (y * width))] * sheetPixels[((x + (xTile * width)) + (y + (yTile * height)) * sheetWidth)];
}
}
}
}
錯誤出現在第7行附近,我似乎無法找出問題所在
您沒有對代碼進行任何分配:
pixels[(x + (y * width))] * sheetPixels[((x + (xTile * width)) + (y + (yTile * height)) * sheetWidth)];
您需要在此處使用值做一些事情,我不確定您要嘗試做的事情(例如可能在數組中設置值等),因此這里僅是示例。
int value = pixels[(x + (y * width))] * sheetPixels[((x + (xTile * width)) + (y + (yTile * height)) * sheetWidth)];
除了您的錯誤,您sheetPixels = new int[width * height];
執行sheetPixels = new int[width * height];
並嘗試使用sheetPixels[...]
從數組中獲取數據后,立即出現了問題,但這與您要求的完全不同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.