I have created my own custom wrapper for AssetManager that loads file using classpath file handle resolver (and later I can get resources only by file name, not the whole path) which works fine. But when I try to load classpath files using Gdx.files.classpath() method, in Eclipse I have to put the source folder name res in the path for it to work and when I export it even with or without the source folder in file’s path, it fails to work.
I tried to create my own custom loader for those files, but that doesn’t work either. In fact, I had to create a whole new project and copy all the files in there because my custom loader somehow messed up all other loaders.
I’ve basically tried everything and nothing works, so my last resort is posting here on JGO in hope for someone to magically appear with the solution. I’m stuck and I cannot finish my project without the possibility to load those level files from classpath. I thought about other solutions, like just putting those files in the same folder as JAR, but I still want to know if someone knows the fix for loading from classpath.
This works both in Eclipse and the exported JAR:
FileEncryptor.initialize();
ResourceManager.load("Graphics/Character1.png", Texture.class);
ResourceManager.load("Graphics/Character2.png", Texture.class);
ResourceManager.load("Graphics/Character3.png", Texture.class);
ResourceManager.load("Graphics/Character4.png", Texture.class);
ResourceManager.load("Graphics/Character5.png", Texture.class);
ResourceManager.load("Graphics/Character6.png", Texture.class);
ResourceManager.load("Graphics/Character7.png", Texture.class);
ResourceManager.load("Graphics/Character8.png", Texture.class);
ResourceManager.load("Graphics/Character9.png", Texture.class);
ResourceManager.load("Graphics/Character10.png", Texture.class);
ResourceManager.load("Graphics/Floor.png", Texture.class);
ResourceManager.load("Graphics/Wall.png", Texture.class);
ResourceManager.load("Graphics/Box.png", Texture.class);
ResourceManager.load("Graphics/Goal.png", Texture.class);
ResourceManager.load("Graphics/BoxOnGoal.png", Texture.class);
Level.loadLevels();
This works in Eclipse, but not the exported JAR:
FileHandle file = Gdx.files.classpath("res/Levels/easy.data");
This doesn’t work in Eclipse AND the exported JAR
FileHandle file = Gdx.files.classpath("Levels/easy.data");
UPDATE #1: Added a screenshot of the exported JAR: