当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Trying to get a list of Files in an internal Folder with libgdx

问题描述:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: