当前位置: 首页>>代码示例>>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;未经允许,请勿转载。