Best Practices for organising assets with different resolutions

Hi All,

I’m working on some proof of concept code for a game that will be run on multiple platforms (i.e. windows, applet, android, etc). The initial results are very positive and the one click deployment successfully generates for each platform and I can run the results etc.

Something I’m not quite sure on though is what is the best way to organise the assets for different distributions. In particular for Android and potentially for Applet use there is no point distributing high resolution textures or images. Whereas for a PC installation users would expect decent quality when they zoom in on something.

I’ve read Hello Assets and run the example program there etc. I’ve also investigated the “Asset Packs” but that seems more like a way of organising assets and distributing them to other people rather than a way to store them for use in programs, as I understand it assets are taken from the Asset Pack and moved into the project when you use the asset.

So is the recommendation just to create JAR files containing the Low and High resolution assets and distribute accordingly? Is there any way to generically load the high resolution if available but if not fall back to the low?

i.e. if I was writing the code I’d be able to do something like “load high res. if high res is null load low res”.

When I’m creating a Nifty GUI though and I put image filename=“foo.jpg” height = “90%” width = “20%” how do I have that pick up the high resolution image if available, but if not fall back to the low resolution one? Similarly when I load a scene j3o that references a material and texture how do I get it to do this?

The simplest solution I can think of at the moment is to create two jars with identical layouts inside, one containing the low and the other the high resolution images. I could then add or remove them as libraries from the project depending on which distribution I’m doing. (I’ve not tested it but I assume they would get picked up as assets). Really I’d much rather not have to keep modifying project settings and rebuilding twice per release. This also limits the options to do clever things like initially using the low resolution images and then pulling down the higher resolution ones in the background.

Is the solution a custom Resource Locator? If I write one of those (or is there already a suitable one?) would Nifty use it too or do I need something specific there?

Sorry for the rambling post but I can see several ways to do this but they all are messy to varying degrees so I was hoping to tap the combined experience of the people here and see if there was a best practices way to do this and/or anything out there already written that I should be using!



You could exclude some assets from the main distribution and pack a jar from them yourself, then add it only to the distributions that you want these specific assets to be in. This will require some work with ANT and the build.xml but in the future it will be easier via the UI. This also allows you to e.g. use different nifty xml files for the UI on each platform to have even substantially different UI’s.


I’m already planning separate nifty XML files. The size of those files is small enough that I don’t mind distributing both though and I was planning to write a generic “load nifty” wrapper that selects the correct one based on the screen size.

What I don’t want to do is include high res textures into the android apk when there is no way they can usefully be used on the android device…

… in fact thinking about it some more its not quite that straightforward as you also have android tablets which have substantially larger screens than a phone. So for both android and non-android versions ideally you want the option to distribute the high resolution textures or not.