Can I clarify the correct way to load assets, specifically so that during development it loads them from the assets/ folder, and when the game is packaged as a jar, it loads them from the jar itself? The only way I seem to be able to do this is to create a flag to tell the software that it’s running as a jar.
If using eclipse just put assets under the resources folder (under src–>main–>resources) They will automatically be put on the classpath in development and when jar is built. Also, you don’t need the assets folder at all following this approach.
Yes, resources (assets) and updater/launcher application in one jar using embedded Felix osgi container and game implementation in a bundle installed (and updatable) to the container. Content would still be loaded via classpath.
That sounds like a overly complicated approach. I do not package my assets into my jars. I leave them in a folder. I also use an external updater jar that is capable of updating assets, libraries, and the main jar. Once the main jar is updated, it downloads a new updater jar. The only thing i distribute is the updater jar, and it performs the downloads for everything.
It is also easier to trouble shoot and debug assets when they are loose files. For distribution sometimes I distribute assets in an external zip.
With external files, it works just fine for the asset loader load from an ide or the app.
I personally recommend using IDEA for development with JME, it works nicely with gradle. Just remember that when using gradle with loose assets, do not map the directory with the assets in it as a resource directory.
My project supports fully dynamic assets - the only assets that need to be distributed are the UI assets (which get bundled into the jar as resources). Everything else is downloaded on the fly as needed and cached for later re-use. Coupled with the entity system, this means that you don’t even need to have all assets for a specific area downloaded before you start playing/interacting with that area - although you will see the world in a partially loaded state while assets download unless the developer forces a loading screen until the area is fully loaded.
This type of asset system is pretty complex, however, and not one I’d recommend replicating unless dynamic assets are a must.