Java源码示例:com.badlogic.gdx.assets.AssetDescriptor
示例1
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle tmxFile, 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 = getRelativeFileHandle(tmxFile, value);
dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
}
}
}
} catch (IOException e) {
throw new GdxRuntimeException("Unable to parse .tmx file.");
}
return dependencies;
}
示例2
@Override
public void show() {
Gdx.app.log(TAG, "Loading act " + (act + 1));
Riiablo.viewport = Riiablo.defaultViewport;
Riiablo.assets.load(loadingscreenDescriptor);
if (dependencies != null) {
for (AssetDescriptor asset : dependencies) {
Riiablo.assets.load(asset);
}
dependencies = null;
}
map.setAct(act);
map.load();
}
示例3
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, ThesaurusLoader.ThesaurusParameter parameter) {
if (parameter != null && parameter.other.length > 0) {
Array<AssetDescriptor> descriptors = new Array<AssetDescriptor>();
for (String depName : parameter.other) {
descriptors.add(new AssetDescriptor<Thesaurus>(depName, Thesaurus.class));
}
return descriptors;
}
return null;
}
示例4
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasLoader.TextureAtlasParameter parameter) {
FileHandle imgDir = file.parent();
map = LyU.createDictionaryWithContentsOfFile(file);
ObjectMap<String, Object> metadata = (ObjectMap<String, Object>) map.get("metadata");
String dependFile = (String) metadata.get("textureFileName");
Array<AssetDescriptor> res = new Array<AssetDescriptor>();
TextureLoader.TextureParameter params = new TextureLoader.TextureParameter();
params.magFilter = Texture.TextureFilter.Linear;
params.minFilter = Texture.TextureFilter.Linear;
params.format = Pixmap.Format.RGBA8888;
texture = new Texture(imgDir.child(dependFile));
res.add(new AssetDescriptor(imgDir.child(dependFile), Texture.class, params));
return res;
}
示例5
@Override
public void dispose() {
x = y = 0;
width = height = 0;
gridSizeX = gridSizeY = 0;
gridsX = gridsY = 0;
tx = ty = 0;
tilesX = tilesY = 0;
free(flags);
flags = null;
for (DT1.Tile[] layer : tiles) free(layer);
Arrays.fill(tiles, null);
//for (Preset[] x : presets) for (Preset y : x) if (y != null) y.dispose();
presets = null;
for (AssetDescriptor asset : dependencies) Riiablo.assets.unload(asset.fileName);
dependencies = EMPTY_ASSET_ARRAY;
dt1s = null; // TODO: setting null -- depending on Map dispose to clear DT1s on act change
town = false;
entities = EMPTY_ENTITY_ARRAY;
warps = EMPTY_INT_INT_MAP;
generator = EMPTY_GENERATOR;
specials = EMPTY_INT_CELL_MAP;
}
示例6
Array<AssetDescriptor> getDependencies() {
if (dependencies == EMPTY_ASSET_ARRAY) {
dependencies = new Array<>(false, 64);
for (Preset[] x : presets) for (Preset y : x) if (y != null) dependencies.addAll(y.getDependencies(type));
}
return dependencies;
}
示例7
void unload(int c, AssetDescriptor[] descriptors) {
AssetDescriptor descriptor = descriptors[c];
if (descriptor == null) return;
descriptors[c] = null;
Riiablo.assets.unload(descriptor.fileName);
if (DEBUG) Gdx.app.debug(TAG, "Unloading[" + Engine.getComposite(c) + "] " + descriptor.fileName);
}
示例8
private void unload(int entityId) {
if (!mCofDescriptor.has(entityId)) return;
CofDescriptor cofDescriptor = mCofDescriptor.get(entityId);
AssetDescriptor<COF> descriptor = cofDescriptor.descriptor;
if (DEBUG) Gdx.app.debug(TAG, "Unloading " + descriptor.fileName);
Riiablo.assets.unload(descriptor.fileName);
mCofDescriptor.remove(entityId);
}
示例9
@Subscribe
public void onCofChanged(CofChangeEvent event) {
if (DEBUG_EVENTS) Gdx.app.debug(TAG, "inserted");
AssetDescriptor<COF> descriptor = mCofDescriptor.get(event.entityId).descriptor;
Riiablo.assets.load(descriptor);
if (DEBUG) Gdx.app.debug(TAG, "Loading " + descriptor.fileName);
checkLoaded(event.entityId);
}
示例10
public LoadingScreen(Array<AssetDescriptor> assets, Screen screen) {
this.screen = screen;
stage = new Stage(Riiablo.defaultViewport, Riiablo.batch);
Riiablo.assets.load(loadingscreenDescriptor);
Riiablo.assets.finishLoadingAsset(loadingscreenDescriptor);
final Animation loadingscreen = Animation.newAnimation(Riiablo.assets.get(loadingscreenDescriptor));
loadingscreen.setFrameDuration(Float.MAX_VALUE);
loadingscreenWrapper = new AnimationWrapper(loadingscreen) {
@Override
public void act(float delta) {
super.act(delta);
for (Animation animation : animations) {
animation.setFrame((int) (Riiablo.assets.getProgress() * (animation.getNumFramesPerDir() - 1)));
}
}
};
loadingscreenWrapper.setPosition(
(stage.getWidth() / 2) - (loadingscreen.getMinWidth() / 2),
(stage.getHeight() / 2) - (loadingscreen.getMinHeight() / 2));
stage.addActor(loadingscreenWrapper);
this.assets = assets;
if (assets != null) {
for (AssetDescriptor asset : assets) {
Riiablo.assets.load(asset);
}
}
}
示例11
@Override
public void dispose() {
Riiablo.assets.unload(questbackgroundDescriptor.fileName);
Riiablo.assets.unload(expquesttabsDescriptor.fileName);
Riiablo.assets.unload(questlastDescriptor.fileName);
Riiablo.assets.unload(buysellbtnDescriptor.fileName);
Riiablo.assets.unload(questdoneDescriptor.fileName);
Riiablo.assets.unload(questsocketsDescriptor.fileName);
for (AssetDescriptor assetDescriptor : questiconsDescriptor) Riiablo.assets.unload(assetDescriptor.fileName);
}
示例12
static Instance obtain(AssetDescriptor descriptor, Object delegate, long id) {
Instance instance = Pools.obtain(Instance.class);
instance.descriptor = descriptor;
instance.stream = delegate instanceof Music;
instance.delegate = delegate;
instance.id = id;
return instance;
}
示例13
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例14
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file,
SceneAssetLoaderParameters parameter) {
return null;
}
示例15
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Professions> parameter) {
return null;
}
示例16
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Levels> parameter) {
return null;
}
示例17
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例18
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Map> parameter) {
return null;
}
示例19
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Abilities> parameter) {
return null;
}
示例20
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Items> parameter) {
return null;
}
示例21
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例22
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例23
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file,
AssetLoaderParameters<MidiSequence> parameter) {
// no dependencies
return null;
}
示例24
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例25
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file,
AssetLoaderParameters<Music> parameter) {
// no dependencies
return null;
}
示例26
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例27
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例28
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例29
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "Couldn't load asset: " + asset.fileName, throwable);
}
示例30
public boolean cast(final int spell) {
if (spell < 0) return false;
if (!isCastable(mode)) return false;
setPath(null, null);
//if (mode == getNeutralMode()) return;
//animating = true;
final Skills.Entry skill = Riiablo.files.skills.get(spell);
byte tm = mode;
byte newMode = type.getMode(skill.anim);
// FIXME: NOTE: I'm think SQ (sequence) used by player spells are hard-coded and indicate
// something like cast + wait. It's possible this is used to block the player
// from using other spells, or somehow resetting the cooldown.
if (newMode == -1) newMode = type.getMode("SC");
boolean changed = sequence(newMode, getNeutralMode());
if (!changed) return false;
/*
updateCOF(); // FIXME: required because we need updated COF to bind to trigger -- should really be done on next frame
for (COF.Keyframe keyframe : COF.Keyframe.values()) {
int frame = animation.getCOF().getKeyframeFrame(keyframe);
System.out.println("keyframe[" + keyframe + "]=" + frame);
}
int frame = animation.getCOF().getKeyframeFrame(COF.Keyframe.ATTACK);
if (frame >= 0) {
animation.addAnimationListener(frame, new Animation.AnimationListener() {
@Override
public void onTrigger(Animation animation, int frame) {
System.out.println("onTrigger " + frame + " " + COF.Keyframe.ATTACK);
animation.removeAnimationListener(frame, this);
}
});
}
*/
System.out.println("cast " + type.MODE[tm] + "->" + type.MODE[mode]);
Riiablo.audio.play(skill.stsound, true);
if (!skill.castoverlay.isEmpty()) {
overlayEntry = Riiablo.files.Overlay.get(skill.castoverlay);
AssetDescriptor<DCC> descriptor = new AssetDescriptor<>("data\\global\\overlays\\" + overlayEntry.Filename + ".dcc", DCC.class);
Riiablo.assets.load(descriptor);
Riiablo.assets.finishLoadingAsset(descriptor);
DCC dcc = Riiablo.assets.get(descriptor);
overlay = Animation.builder()
.layer(dcc, overlayEntry.Trans == 3 ? BlendMode.LUMINOSITY : BlendMode.ID)
.build();
overlay.setMode(Animation.Mode.ONCE);
//overlay.setFrameDuration(1f / overlayEntry.AnimRate);
}
return true;
}