Azzet - Asset loading library

Azzet is a simple library I created awhile back but finally decided to put it up on GitHub.

It is an asset loading framework where you can pull assets from various sources in various formats. You can add your own formats and sources if you want.

Code Example:


BufferedImage img = Assets.load("http://www.google.com/logos/classicplus.png"); // loaded from website
Font fnt = Assets.load("myfont.ttf", new FontInfo(32.0f)); // loaded from classpath
Clip snd = Assets.load("C:\UserData\MyMusic.wav"); // loaded from file-system
BufferedImage[] gif = Assets.loadFrom("mygif", "db"); // loads from DatabaseSource saved as "db"
Properties props = Assets.loadFrom("app.properties", "tcp"); // loads from TcpSource saved as "tcp"

Checkout the README for the link to examples, documentation, and downloads.

If you have any format requests (I was debating about adding a JOGL/LWJGL branch for Textures and Audio or something…) OR problems please let me know.

Let me know what you think!

Thanks


BufferedImage[] gif = Assets.loadFrom("mygif", "db"); // loads from DatabaseSource saved as "db"
Properties props = Assets.loadFrom("app.properties", "tcp"); // loads from TcpSource saved as "tcp"

How does it know the first was a DatabaseSource and the second was a TcpSource?

You add the sources at the start of the program:


Assets.addSource( "db", new DatabaseSource( getConnection(), "SELECT asset FROM asset_table WHERE name = ?" ) );
Assets.addSource( "tcp", new TcpSource( "129.24.84.10", 858 ) );

See the documentation for the Assets class (specifically loadFrom)

http://clickermonkey.github.com/azzet/

I like the API (methods), but a class parameter will be nice for readability. Like

Clip snd = Assets.load("C:\UserData\MyMusic.wav", Clip.class);

You can do that =)

Edit:

Here are all the load methods:


load(String request) 
load(String request, AssetInfo requestInfo) 
load(String request, Class<A> requestType)
load(String request, String requestExtension) 
load(String request, String requestExtension, AssetInfo requestInfo) 
loadFrom(String request, String sourceName) 
loadFrom(String request, String sourceName, AssetInfo requestInfo) 
loadFrom(String request, String sourceName, Class<A> requestType) 
loadFrom(String request, String sourceName, String requestExtension) 
loadFrom(String request, String sourceName, String requestExtension, AssetInfo requestInfo) 

Just added background loading!

Here’s an example of using FutureAssetBundle (opposed to handling the FutureAssets directly and checking the status of each):


 FutureAssetBundle bundle = new FutureAssetBundle();
 bundle.add( Assets.loadFuture("image.gif", BufferedImage.class) );
 bundle.add( Assets.loadFuture("sound.wav", Clip.class) );
 
 BufferedImage image = null;
 Clip sound = null;
 
 while (running) {
 	   // do stuff
     
     if (bundle.isComplete()) {
         bundle.loaded(); // notify all FutureAsset implementations the asset has been accepted.
         image = bundle.getAsset("image.gif");
         sound = bundle.getAsset("sound.wav");
         // move from loading to play screen
     } else {
         display bundle.percentComplete();     
     }
     
     // do other stuff
 }

So now there are loadFuture and loadFutureFrom methods that return FutureAsset.

seems pretty dope

since I use Libgdx I really value a good asset system

Yeah it looks like libgdx’s AssetManager (at least from the front). What I like from this is static ;D

Hmm I’ll have to look at LibGDX’s… I’ve never used it… my original design for this was half inspired by JME’s… perhaps LibGDX’s was as well.

http://code.google.com/p/libgdx-users/wiki/AssetManager

However I encounter weird problem with the manager on my latest android game.

http://www.java-gaming.org/index.php/topic,28682.new.html

The example on that page is out of date, here’s the correct url (looks like libgdx moved from google code to github):

Yeah I read your post, I swear a few weeks ago I read someone else also having this error… like OpenGL (or whatever backend) did not properly or completely release a texture on shutdown… so when they restarted it seemed to still be loaded… or perhaps it was because the texture IDs were used but actually weren’t… or maybe the opposite of that. Either way, I don’t use LibGDX so I’m no expert.

Maybe I should call dispose() before exit(). On the docs it says “Exits the application. On android, this will cause a call to pause() and dispose() some time in the future, it will not immediately finish your application.”.

I dont know if you plan to make this lib android-compatible too but hope you can consider this too while dev :slight_smile: