本文整理汇总了Java中com.badlogic.gdx.assets.AssetLoaderParameters类的典型用法代码示例。如果您正苦于以下问题:Java AssetLoaderParameters类的具体用法?Java AssetLoaderParameters怎么用?Java AssetLoaderParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssetLoaderParameters类属于com.badlogic.gdx.assets包,在下文中一共展示了AssetLoaderParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAsset
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
private static <T, P extends AssetLoaderParameters<T>> void loadAsset(String filePath, Class<T> type, AssetLoader<T, P> loader) {
if (filePath == null || filePath.trim().isEmpty()) {
Gdx.app.debug(TAG, "Trying to load a " + type.getSimpleName() + " with empty filePath");
return;
}
if (fileResolver.resolve(filePath).exists()) {
assetManager.setLoader(type, loader);
assetManager.load(filePath, type);
assetManager.finishLoading();
Gdx.app.debug(TAG, type.getSimpleName() + " loaded: " + filePath);
} else {
Gdx.app.debug(TAG, type.getSimpleName() + " does not exist: " + filePath);
}
}
示例2: loadAsync
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override @SuppressWarnings("unchecked") public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Levels> parameter) {
Yaml yaml = new Yaml();
ObjectMap<String, BaseLevelDescription> data = new ObjectMap<String, BaseLevelDescription>();
for (Object o : yaml.loadAll(resolve(fileName).read())) {
HashMap<String, Object> value = (HashMap<String, Object>) o;
String type = MapHelper.get(value, "type", "level");
try {
BaseLevelDescription desc = types.get(type).getConstructor(Map.class).newInstance(value);
data.put(desc.name, desc);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
levels = new Levels(data);
Config.levels = levels;
}
示例3: handleImports
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
public static <T, P extends AssetLoaderParameters<T>> void handleImports(
AssetLoader<T, P> loader, P parameter,
@SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies, FileHandle parentFile,
Element root) throws IOException {
Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
for (Element singleImport : imports) {
String filename = singleImport.get(XMLUtil.XML_FILENAME);
FileHandle file = parentFile.parent().child(filename);
if (!file.exists()) {
throw new GdxRuntimeException("Import " + file.path()
+ " from import for " + parentFile.name()
+ " does not exist.");
}
dependencies.addAll(loader.getDependencies(filename, file, parameter));
}
}
示例4: getLoadParams
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override
@Nullable
protected AssetLoaderParameters<Texture> getLoadParams(FilePath imagePath) {
IImageDefinition imageDef = getImageDef(imagePath);
if (imageDef == null) {
return null;
}
TextureParameter params = new TextureParameter();
params.minFilter = GdxTextureUtil.toGdxFilter(imageDef.getMinifyFilter());
params.magFilter = GdxTextureUtil.toGdxFilter(imageDef.getMagnifyFilter());
params.wrapU = GdxTextureUtil.toGdxWrap(imageDef.getTilingModeX());
params.wrapV = GdxTextureUtil.toGdxWrap(imageDef.getTilingModeY());
return params;
}
示例5: load
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
public <T> T load (String resource, Class<T> type, AssetLoader loader, AssetLoaderParameters<T> params) {
String resolvedPath = new String(resource).replaceAll("\\\\", "/");
boolean exist = assetManager.isLoaded(resolvedPath, type);
T oldAsset = null;
if(exist){
oldAsset = assetManager.get(resolvedPath, type);
for(int i=assetManager.getReferenceCount(resolvedPath); i > 0; --i)
assetManager.unload(resolvedPath);
}
AssetLoader<T, AssetLoaderParameters<T>> currentLoader = assetManager.getLoader(type);
if(loader != null)
assetManager.setLoader(type, loader);
assetManager.load(resource, type, params);
assetManager.finishLoading();
T res = assetManager.get(resolvedPath);
if(currentLoader != null)
assetManager.setLoader(type, currentLoader);
if(exist)
EventManager.get().fire(EVT_ASSET_RELOADED, new Object[]{oldAsset, res});
return res;
}
示例6: makeAssetLoaderParameter
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
private <T> AssetLoaderParameters<T> makeAssetLoaderParameter(String fileName, Class<T> type) {
AssetLoaderParameters<T> parameter;
if (type.equals(Texture.class)) {
parameter = (AssetLoaderParameters<T>) new TextureLoader.TextureParameter();
} else if (type.equals(TextureAtlas.class)) {
parameter = (AssetLoaderParameters<T>) new TextureAtlasLoader.TextureAtlasParameter();
} else if (type.equals(Sound.class)) {
parameter = (AssetLoaderParameters<T>) new SoundLoader.SoundParameter();
} else if (type.equals(BitmapFont.class)) {
parameter = (AssetLoaderParameters<T>) new BitmapFontLoader.BitmapFontParameter();
} else if (type.equals(Pixmap.class)) {
parameter = (AssetLoaderParameters<T>) new PixmapLoader.PixmapParameter();
} else if (type.equals(Music.class)) {
parameter = (AssetLoaderParameters<T>) new MusicLoader.MusicParameter();
} else {
parameter = null;
}
return parameter;
}
示例7: loadAsync
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override
public void loadAsync(AssetManager manager, String fileName,
FileHandle file, AssetLoaderParameters<T> parameter) {
// FIXME temporary fix. Some of the files has erroneous '
String contents = file
.readString()
.replaceAll(
"'(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?(\\?.*)?'",
"\"http\"");
object = gameAssets.fromJson(clazz == Object.class ? null : clazz,
contents);
if (object == null) {
throw new RuntimeException(fileName
+ " name is an empty file. Impossible to load json");
}
}
示例8: loadAndGet
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
public synchronized <T> T loadAndGet(String fileName, Class<T> type, AssetLoaderParameters<T> parameter) {
if (!isLoaded(fileName)) {
load(fileName, type, parameter);
finishLoadingAsset(fileName);
}
return super.get(fileName, type);
}
示例9: loadAsync
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Professions> parameter) {
Yaml yaml = new Yaml();
ObjectMap<String, ProfessionDescription> data = new ObjectMap<String, ProfessionDescription>();
for (Object o : yaml.loadAll(resolve(fileName).read())) {
Map professionData = (Map) o;
ProfessionDescription profession = new ProfessionDescription(professionData);
data.put(profession.name, profession);
}
professions = new Professions(data);
Config.professions = professions;
}
示例10: loadAsync
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Array> parameter) {
Iterable<Object> data = new Yaml().loadAll(file.read());
Array<Object> list = new Array<Object>();
for(Object o : data){
list.add(o);
}
this.list = list;
}
示例11: loadAsync
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override @SuppressWarnings("unchecked") public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Abilities> parameter) {
Yaml yaml = new Yaml();
ObjectMap<String, Ability> data = new ObjectMap<String, Ability>();
for (Object o : yaml.loadAll(resolve(fileName).read())) {
HashMap<String, Object> value = (HashMap<String, Object>) o;
Ability description = new Ability(value);
data.put(description.name, description);
}
abilities = new Abilities(data);
Config.abilities = abilities;
}
示例12: loadAsync
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Items> parameter) {
Constructor constructor = new Constructor(Item.class);
Yaml yaml = new Yaml(constructor);
ObjectMap<String, Item> data = new ObjectMap<String, Item>();
for (Object o : yaml.loadAll(resolve(fileName).read())) {
Item item = (Item) o;
data.put(item.name, item);
}
items = new Items(data);
Config.items = items;
}
示例13: load
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@Override
public synchronized <T> void load(String fileName, Class<T> type,
AssetLoaderParameters<T> parameter) {
if (fileName.contains(TEXTURE_REGION_SEPARATOR)) {
fileName = fileName.substring(0, fileName.lastIndexOf(TEXTURE_REGION_SEPARATOR)+TEXTURE_REGION_SEPARATOR_LENGTH-1);
super.load(fileName, TextureAtlas.class, null);
} else {
super.load(fileName, type, parameter);
}
}
示例14: getDependencies
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Scene> parameter) {
scene = new Json().fromJson(Scene.class, serializedScene);
Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
for (int i = 0; i < scene.gameObjects.size; i++)
scene.gameObjects.get(i).load(assetDependencies);
return assetDependencies;
}
示例15: getDependencies
import com.badlogic.gdx.assets.AssetLoaderParameters; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Project> parameter) {
project = new Json().fromJson(Project.class, file.readString());
Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
return assetDependencies;
}