Im trying to make a level selection screen for a game
FileHandle dirHandle;
if(Gdx.app.getType() == ApplicationType.Android){
dirHandle = Gdx.files.internal("levels/");
} else{
dirHandle = Gdx.files.internal("./bin/levels");
}
for(FileHandle level : dirHandle.list()){
if(!level.name().equals("new_tileset.png") ){
Button mButton = new Button(buttonStyle);
mButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
// TODO Auto-generated method stub
game.setScreen(new GamePlay(game,level));
}
});
mTable.add(mButton);
}
}
this code seems to work on android and on desktop except when i export my project as an executable jar, there are no levels show, dirHandle.list() returns an empty array. Is there a work around for accessing files in my assets folder on desktop?
-Edit- ok i tweaked my code a bit and it seems to work when i export it now. But it does not work when im running it from eclipse. Also when i upload the jar and download it and test it, the same thing happens, no levels show and dirHandle.list() is empty, i have no idea whats going on