v0.8.1: sound assets now load async, much faster initial load times
This commit is contained in:
parent
c9636a9c8b
commit
cf085cc15c
|
@ -57,16 +57,21 @@ public enum Sample {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load( String... assets ) {
|
public void load( final String... assets ) {
|
||||||
|
|
||||||
//FIXME there used to be a queue here so that assets were loaded async.
|
//load in a separate thread to prevent this blocking the UI
|
||||||
//This was to prevent hanging on specific android versions (implement in vanilla v1.7.5)
|
new Thread(){
|
||||||
//Maybe LibGDX already handles this?
|
@Override
|
||||||
for (String asset : assets){
|
public void run() {
|
||||||
if (!ids.containsKey(asset)){
|
synchronized (Sample.class) {
|
||||||
|
for (String asset : assets) {
|
||||||
|
if (!ids.containsKey(asset)) {
|
||||||
ids.put(asset, Gdx.audio.newSound(Gdx.files.internal(asset)));
|
ids.put(asset, Gdx.audio.newSound(Gdx.files.internal(asset)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user