2

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

user3712476
  • 118
  • 1
  • 11
  • possible duplicate of [Managing assets between desktop and device version in libgdx](http://stackoverflow.com/questions/9892964/managing-assets-between-desktop-and-device-version-in-libgdx) – donfuxx Aug 28 '14 at 20:22
  • Mmm I don't think so, one of the answers mentions to link your android assets folder to your desktop, but my project already has these folders linked(I'm assuming the libgdx project set up jar did it for me) – user3712476 Aug 29 '14 at 00:05

0 Answers0