gavioto / playn

Automatically exported from code.google.com/p/playn
0 stars 0 forks source link

Assets should provide a way to register listener #151

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if Assets was implementing the same "observable" facilities as 
AssetWatcher, so that you can easily add a listener to listen for Done or Error 
event.

Something like:
assets().Done(new Listener() {
    public void done() {
        startGame();
    }
    public void error(Throwable e) {
        ...
    }
})

Original issue reported on code.google.com by pro...@google.com on 13 Mar 2012 at 6:17

GoogleCodeExporter commented 9 years ago

Original comment by pro...@google.com on 13 Mar 2012 at 6:17

GoogleCodeExporter commented 9 years ago

Original comment by pro...@google.com on 13 Mar 2012 at 6:17

GoogleCodeExporter commented 9 years ago
+1, but I would call it setListener or addListener.

I would even deprecate isDone because it causes programmer to ignore errors 
that can happen during loading. 

Original comment by yzibin@google.com on 13 Mar 2012 at 6:22

GoogleCodeExporter commented 9 years ago
Why is it hard to create an asset watcher and add your assets to it? You could 
even create a facade for Assets which had a built in watcher and load your 
assets via that.

I'd rather not make the Assets API bigger just to support this one, not very 
common, use case. Most games will load and watch assets on a more fine grained 
basis than just "I load all my assets once at the beginning of the game and 
then never care about watching assets again."

Original comment by m...@samskivert.com on 13 Mar 2012 at 7:05

GoogleCodeExporter commented 9 years ago
I just created another quite similar issue. If desired I could contribute an 
updated AssetWatcher that also uses the correct Callbacks and makes sure not to 
break existing code by adding stuff to the AssetWatcher itself instead of 
changing the Listener (attached).

Original comment by dc...@dcode.io on 30 Oct 2012 at 5:57

Attachments: