EDIT: It correctly finds files, just not folders.
I’m trying for the first time to parse files. I have a folder called “file” and inside that a folder called “Test folder”. I want to be able to write the Test folder’s name (Which is ‘Test Folder’) in the middle of the screen. However, when I do that I get an array index out of bounds exception which I suppose means it’s not finding a folder inside the “file” folder.
What I have:
public class MenuScreen implements Screen {
Core core;
public OrthographicCamera cam;
public StretchViewport stretchViewport;
public FileHandle[] fileList;
private BitmapFont font;
private SpriteBatch spriteBatch;
public MenuScreen(Core core){
this.core = core;
}
@Override
public void show() {
cam = new OrthographicCamera(480, 640);
stretchViewport = new StretchViewport(480, 640, cam);
stretchViewport.apply();
font = new BitmapFont();
spriteBatch = new SpriteBatch();
// Initalize folder list
fileList = Gdx.files.local("file/").list();
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(243f/255f,163f/255f,109f/255f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam.update();
spriteBatch.begin();
font.draw(spriteBatch, fileList[0].toString(), 480/2, 640/2);
spriteBatch.end();
}
@Override
public void resize(int width, int height) {
stretchViewport.setWorldSize(width, height);
}