本文整理汇总了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;
}
}
}