當前位置: 首頁>>代碼示例>>Java>>正文


Java Disposable類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:cpppwner,項目名稱:NoRiskNoFun,代碼行數:31,代碼來源:LibGdxAssetCache.java

示例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;
    }
}
 
開發者ID:Xemiru,項目名稱:Undertailor,代碼行數:30,代碼來源:ResourceFactory.java

示例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;
    });
}
 
開發者ID:Xemiru,項目名稱:Undertailor,代碼行數:19,代碼來源:TilemapFactory.java

示例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();
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:17,代碼來源:EngineStateClosing.java

示例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();
}
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:22,代碼來源:BaseBulletTest.java

示例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.
    }
}
 
開發者ID:gdx-libs,項目名稱:gdx-autumn,代碼行數:17,代碼來源:DisposeAnnotationProcessor.java

示例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;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:26,代碼來源:ModelLoader.java

示例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();
}
 
開發者ID:jrenner,項目名稱:gdx-proto,代碼行數:19,代碼來源:Physics.java

示例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;
}
 
開發者ID:jrenner,項目名稱:gdx-proto,代碼行數:26,代碼來源:HeadlessModelLoader.java

示例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;
}
 
開發者ID:libgdx,項目名稱:gdx-ai,代碼行數:19,代碼來源:BulletSteeringTest.java

示例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();
    }
  }
}
 
開發者ID:isnuryusuf,項目名稱:ingress-indonesia-dev,代碼行數:17,代碼來源:Skin.java

示例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.");
}
 
開發者ID:isnuryusuf,項目名稱:ingress-indonesia-dev,代碼行數:21,代碼來源:a.java

示例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();
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:8,代碼來源:TDScreen.java

示例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;
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:36,代碼來源:NhgModelLoader.java

示例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;
		}
	}
}
 
開發者ID:exch-bms2,項目名稱:beatoraja,代碼行數:9,代碼來源:SkinObject.java


注:本文中的com.badlogic.gdx.utils.Disposable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。