本文整理汇总了Java中com.badlogic.gdx.assets.AssetDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java AssetDescriptor类的具体用法?Java AssetDescriptor怎么用?Java AssetDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssetDescriptor类属于com.badlogic.gdx.assets包,在下文中一共展示了AssetDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDependencies
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
try {
root = xml.parse(tmxFile);
Element properties = root.getChildByName("properties");
if (properties != null) {
for (Element property : properties.getChildrenByName("property")) {
String name = property.getAttribute("name");
String value = property.getAttribute("value");
if (name.startsWith("atlas")) {
FileHandle atlasHandle = Gdx.files.internal(value);
dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
}
}
}
} catch (IOException e) {
throw new GdxRuntimeException("Unable to parse .tmx file.");
}
return dependencies;
}
示例2: handleImports
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的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));
}
}
示例3: getDependencies
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ProjectileTypeParameter parameter) {
XmlReader xmlReader = new XmlReader();
try {
Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
Element root = xmlReader.parse(file);
LoaderUtil.handleImports(this, parameter, returnValue, file, root);
String animationFile = root.get(ProjectileType.XML_ANIMATION_FILE, null);
if (animationFile != null) {
returnValue.add(new AssetDescriptor<Texture>(Configuration.addModulePath(animationFile), Texture.class));
}
Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
if (soundsElement != null) {
addSoundDependency(soundsElement, ProjectileType.XML_ON_START, returnValue);
addSoundDependency(soundsElement, ProjectileType.XML_ON_HIT, returnValue);
addSoundDependency(soundsElement, ProjectileType.XML_DURING, returnValue);
}
if (returnValue.size > 0) {
return returnValue;
}
} catch (IOException e) {
throw new GdxRuntimeException(e);
}
return null;
}
示例4: getDependencies
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, WeatherProfileParameter parameter) {
Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
try {
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(file);
LoaderUtil.handleImports(this, parameter, returnValue, file, root);
Array<Element> trackElements = root.getChildrenByNameRecursively(WeatherProfile.XML_TRACK);
for (Element trackElement : trackElements) {
String trackFileName = Configuration.addModulePath(trackElement.get(XMLUtil.XML_ATTRIBUTE_FILENAME));
returnValue.add(new AssetDescriptor(trackFileName, WeatherProfile.XML_CONTINOUS.equalsIgnoreCase(trackElement.getParent().getName()) ? Music.class : Sound.class));
}
} catch (IOException e) {
throw new GdxRuntimeException(e);
}
return returnValue;
}
示例5: getDependencies
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, TrapParameter parameter) {
XmlReader xmlReader = new XmlReader();
try {
Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
Element root = xmlReader.parse(file);
LoaderUtil.handleImports(this, parameter, returnValue, file, root);
Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
if (soundsElement != null) {
addSoundDependency(soundsElement, TrapType.XML_DISARMED, returnValue);
addSoundDependency(soundsElement, TrapType.XML_SPRUNG, returnValue);
}
if (returnValue.size > 0) {
return returnValue;
}
} catch (IOException e) {
throw new GdxRuntimeException(e);
}
return null;
}
示例6: getDependencies
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@Override
public Array<AssetDescriptor> getDependencies(String fileName,
FileHandle file, Parameter parameter) {
JsonValue root = reader.parse(file);
String spineFile = root.getString("spine");
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
dependencies.add(new AssetDescriptor(
spineFile,
SkeletonData.class,
getSkeletonParameters(spineFile)
));
return dependencies;
}
示例7: MAIN_FONT_19_PATH
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
public final AssetDescriptor<BitmapFont> MAIN_FONT_19_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/AlemdraSC/AlmendraSC-Regular.ttf";
font.fontParameters.size = 19;
return new AssetDescriptor<BitmapFont>("mainFont19.ttf",
BitmapFont.class, font);
}
示例8: MAIN_FONT_22_PATH
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
public final AssetDescriptor<BitmapFont> MAIN_FONT_22_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/AlemdraSC/AlmendraSC-Regular.ttf";
font.fontParameters.size = 22;
return new AssetDescriptor<BitmapFont>("mainFont22.ttf",
BitmapFont.class, font);
}
示例9: LETTER_FONT_20_PATH
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
public final AssetDescriptor<BitmapFont> LETTER_FONT_20_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/Fredericka_the_Great/FrederickatheGreat-Regular.ttf";
font.fontParameters.size = 20;
return new AssetDescriptor<BitmapFont>("letterFont20.ttf",
BitmapFont.class, font);
}
示例10: HANDWRITTEN_FONT_20_PATH
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
public final AssetDescriptor<BitmapFont> HANDWRITTEN_FONT_20_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/ReenieBeanie/ReenieBeanie.ttf";
font.fontParameters.size = 20;
return new AssetDescriptor<BitmapFont>("handwrittenFont20.ttf",
BitmapFont.class, font);
}
示例11: update
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@Override
public synchronized boolean update () {
boolean done = super.update();
if (done) {
// assign references to Asset fields of queuedContainers
for (Object assetContainer : queuedContainers) {
ObjectMap<Field, AssetDescriptor<?>> fieldsToAssets = containersFieldsToAssets.get(assetContainer);
for (ObjectMap.Entry<Field, AssetDescriptor<?>> fieldEntry : fieldsToAssets) {
Field field = fieldEntry.key;
makeAccessible(field);
try {
field.set(assetContainer, get(fieldEntry.value));
} catch (ReflectionException e) {
throw new GdxRuntimeException("Failed to assign loaded asset " + field.getName(), e);
}
}
ObjectMap<Object[], AssetDescriptor<?>[]> fieldsToAssetArrays = containersFieldsToAssetArrays.get(assetContainer);
for (ObjectMap.Entry<Object[], AssetDescriptor<?>[]> arrayEntry : fieldsToAssetArrays) {
Object[] destinationArray = arrayEntry.key;
AssetDescriptor<?>[] descriptors = arrayEntry.value;
for (int i = 0; i < descriptors.length; i++) {
destinationArray[i] = get(descriptors[i]);
}
}
if (assetContainer instanceof AssetContainer)
((AssetContainer) assetContainer).onAssetsLoaded();
}
loadedContainers.addAll(queuedContainers);
queuedContainers.clear();
}
return done;
}
示例12: error
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
try {
throw throwable;
} catch (Throwable e) {
Logger.getInstance().error(e.getMessage());
e.printStackTrace();
}
}
示例13: error
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
try {
throw throwable;
} catch (Throwable throwable1) {
throwable1.printStackTrace();
}
}
示例14: getDependencies
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, P parameters) {
final Array<AssetDescriptor> deps = new Array();
ModelData data = loadModelData(file, parameters);
if (data == null) return deps;
ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
item.key = fileName;
item.value = data;
synchronized (items) {
items.add(item);
}
TextureLoader.TextureParameter textureParameter = (parameters != null)
? parameters.textureParameter
: defaultParameters.textureParameter;
for (final ModelMaterial modelMaterial : data.materials) {
if (modelMaterial.textures != null) {
for (final ModelTexture modelTexture : modelMaterial.textures) {
String fName = modelTexture.fileName;
if (fName.contains("/")) {
fName = fName.substring(fName.lastIndexOf("/") + 1);
}
deps.add(new AssetDescriptor(currentAsset.dependenciesPath + fName, Texture.class, textureParameter));
}
}
}
return deps;
}
示例15: loadLevelAsset
import com.badlogic.gdx.assets.AssetDescriptor; //导入依赖的package包/类
private void loadLevelAsset(
AssetManager assMan,
LevelParameters levelParameters,
String assetPath,
Class assetClass)
{
@SuppressWarnings("unchecked")
AssetDescriptor assetDescriptor =
new AssetDescriptor(assetPath, assetClass);
assMan.load(assetDescriptor);
levelParameters.dependencies.add(assetDescriptor);
}