public PImage[] images;
public static File[] wallTiles = loadFolder("data/tiles/walls");
public static File[] floorTiles = loadFolder("data/tiles/floors");
public static int totalFiles = wallTiles.length+floorTiles.length;
private static File[] loadFolder(String string)
{
File files = new File(string);
File[] pngFiles = files.listFiles(new FilenameFilter()
{
public boolean accept(File directory, String fileName)
{
return fileName.endsWith(".png");
};
});
return pngFiles;
}
分配了 totalFiles 的第 4 行总是失败,因为 wallTiles 为空。我想返回这个类(称为 Art)中的 totalFiles,这样我就可以为我正在开发的游戏随机选择墙壁或地板纹理。感谢收听。