本文整理匯總了Java中com.badlogic.gdx.utils.Disposable類的典型用法代碼示例。如果您正苦於以下問題:Java Disposable類的具體用法?Java Disposable怎麽用?Java Disposable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Disposable類屬於com.badlogic.gdx.utils包,在下文中一共展示了Disposable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: release
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
/**
* Helper method to release a cached asset (texture, sound, font, ...).
*
* <p>
* If {@link RefCountedAsset#release()} returns {@code true}, the asset is also
* removed from the cache.
* </p>
*
* @param cache The cache where to search for the asset to be released.
* @param valueToRelease The asset to release.
* @param <K> Key type in the {@code Map}.
* @param <T> The asset type.
*/
private static <K, T extends Disposable> void release(Map<K, RefCountedAsset<T>> cache,
T valueToRelease) {
K keyToRemove = null;
for (Map.Entry<K, RefCountedAsset<T>> entry : cache.entrySet()) {
if (entry.getValue().wrapsAsset(valueToRelease)) {
if (entry.getValue().release()) {
keyToRemove = entry.getKey();
}
break;
}
}
if (keyToRemove != null) {
cache.remove(keyToRemove);
}
}
示例2: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
/**
* Disposes of the underlying {@link Resource} and
* {@link Disposable} pair held by this
* {@link ResourceFactory}.
*/
public final void dispose() {
this.onDispose();
if(this.disposableGen != null) {
this.cancelGen = true;
}
if (this.disposable != null) {
if (this.disposeOnGameThread()) {
Disposable copy = this.disposable;
Gdx.app.postRunnable(() -> copy.dispose());
} else {
this.disposable.dispose();
}
this.disposable = null;
}
if (this.reference != null) {
if (this.reference.get() != null)
this.reference.get().disposable = null;
this.reference.enqueue();
this.reference = null;
}
}
示例3: loadDisposable
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
protected CompletableFuture<Disposable> loadDisposable() {
return CompletableFuture.supplyAsync(() -> {
try {
reader.read(tmxFile, this.getResourceReference());
} catch (Exception e) {
String message = "Failed to load tilemap " + this.tmxFile.getAbsolutePath() + " ("
+ e.getMessage() + ")";
BadAssetException thrown = new BadAssetException(message);
thrown.initCause(e);
Thread.getDefaultUncaughtExceptionHandler()
.uncaughtException(Thread.currentThread(), thrown);
}
return null;
});
}
示例4: enter
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public void enter(NhgEntry nhgEntry) {
NhgLogger.log(this, "Engine is closing.");
nhgEntry.onClose();
ImmutableBag<BaseSystem> systems = nhgEntry.nhg.entities.getEntitySystems();
for (BaseSystem bs : systems) {
if (bs instanceof Disposable) {
((Disposable) bs).dispose();
}
}
nhgEntry.nhg.assets.dispose();
nhgEntry.nhg.threading.terminate();
Gdx.app.exit();
}
示例5: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public void dispose () {
world.dispose();
world = null;
for (Disposable disposable : disposables)
disposable.dispose();
disposables.clear();
modelBatch.dispose();
modelBatch = null;
shadowBatch.dispose();
shadowBatch = null;
if (shadows)
((DirectionalShadowLight)light).dispose();
light = null;
super.dispose();
}
示例6: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public void dispose() {
try {
final Object value = Reflection.getFieldValue(field, fieldOwner);
if (value instanceof Disposable) {
((Disposable) value).dispose();
} else if (value instanceof Lazy<?>) {
final Lazy<?> lazy = (Lazy<?>) value;
if (lazy.isInitialized() && lazy.get() instanceof Disposable) {
((Disposable) lazy.get()).dispose();
}
}
} catch (final Exception exception) {
Exceptions.ignore(exception); // Ignored. Closing the application, invalid objects can occur.
}
}
示例7: loadSync
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public Model loadSync (AssetManager manager, String fileName, FileHandle file, P parameters) {
ModelData data = null;
synchronized (items) {
for (int i = 0; i < items.size; i++) {
if (items.get(i).key.equals(fileName)) {
data = items.get(i).value;
items.removeIndex(i);
}
}
}
if (data == null) return null;
final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
// need to remove the textures from the managed disposables, or else ref counting
// doesn't work!
Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
while (disposables.hasNext()) {
Disposable disposable = disposables.next();
if (disposable instanceof Texture) {
disposables.remove();
}
}
data = null;
return result;
}
示例8: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public void dispose() {
for (Disposable disp : disposables) {
/*if (disp instanceof BulletBase) {
System.out.println("ownership: " + ((BulletBase) disp).hasOwnership());
}*/
Tools.dispose(disp);
}
for (btCollisionShape shape : shapes) {
shape.dispose();
}
for (btCollisionObject object : objects) {
object.dispose();
}
disposables.clear();
shapes.clear();
objects.clear();
}
示例9: loadSync
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public HeadlessModel loadSync (AssetManager manager, String fileName, FileHandle file, P parameters) {
ModelData data = null;
synchronized (items) {
for (int i = 0; i < items.size; i++) {
if (items.get(i).key.equals(fileName)) {
data = items.get(i).value;
items.removeIndex(i);
}
}
}
if (data == null) return null;
final HeadlessModel result = new HeadlessModel(data, new TextureProvider.AssetTextureProvider(manager));
// need to remove the textures from the managed disposables, or else ref counting
// doesn't work!
Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
while (disposables.hasNext()) {
Disposable disposable = disposables.next();
if (disposable instanceof Texture) {
disposables.remove();
}
}
data = null;
return result;
}
示例10: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public void dispose () {
world.dispose();
world = null;
for (Disposable disposable : disposables)
disposable.dispose();
disposables.clear();
modelBatch.dispose();
modelBatch = null;
shadowBatch.dispose();
shadowBatch = null;
if (shadows) ((DirectionalShadowLight)light).dispose();
light = null;
}
示例11: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
public void dispose()
{
if (this.atlas != null)
this.atlas.dispose();
Iterator localIterator1 = this.resources.values().iterator();
while (localIterator1.hasNext())
{
Iterator localIterator2 = ((ObjectMap)localIterator1.next()).values().iterator();
while (localIterator2.hasNext())
{
Object localObject = localIterator2.next();
if ((localObject instanceof Disposable))
((Disposable)localObject).dispose();
}
}
}
示例12: a
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
public final bj a(i parami, ba paramba, ai paramai)
{
if (this.b.tryAcquire())
{
if (parami.d(paramba))
{
Disposable localDisposable = parami.b(paramba).a();
if ((localDisposable instanceof c))
{
c localc = (c)localDisposable;
if (localc.b())
return new l(this.d, localc.c());
}
}
if ((ag.a == ah.a) && (parami.e(paramba)))
new Object[1][0] = paramba.b();
return new d(this.c, "sounds", paramai);
}
throw new bl("acquireSoundPlayer too many sound players.");
}
示例13: dispose
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public void dispose () {
System.out.println("Dispose");
if (disposables != null)
for (Disposable d : disposables)
d.dispose();
}
示例14: loadSync
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
@Override
public Model loadSync(AssetManager manager, String fileName, FileHandle file, P parameters) {
ModelData data = null;
synchronized (items) {
for (int i = 0; i < items.size; i++) {
if (items.get(i).key.equals(fileName)) {
data = items.get(i).value;
items.removeIndex(i);
}
}
}
if (data == null) return null;
final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
// need to remove the textures from the managed disposables, or else ref counting
// doesn't work!
Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
while (disposables.hasNext()) {
Disposable disposable = disposables.next();
if (disposable instanceof Texture) {
disposables.remove();
}
}
// Automatically convert all materials to PBR
for (Material material : result.materials) {
TextureAttribute textureAttribute = (TextureAttribute) material.get(TextureAttribute.Diffuse);
if (textureAttribute != null) {
material.set(PbrTextureAttribute.createAlbedo(textureAttribute.textureDescription.texture));
}
}
data = null;
return result;
}
示例15: disposeAll
import com.badlogic.gdx.utils.Disposable; //導入依賴的package包/類
public static void disposeAll(Disposable[] obj) {
for(int i = 0;i < obj.length;i++) {
if(obj[i] != null) {
obj[i].dispose();
obj[i] = null;
}
}
}