use of com.esotericsoftware.spine.Animation in project bladecoder-adventure-engine by bladecoder.
the class SpineRenderer method getInternalAnimations.
@Override
public String[] getInternalAnimations(AnimationDesc anim) {
try {
retrieveSource(anim.source, ((SpineAnimationDesc) anim).atlas);
} catch (GdxRuntimeException e) {
sourceCache.remove(anim.source);
Array<String> dependencies = EngineAssetManager.getInstance().getDependencies(getFileName(anim.source));
if (dependencies.size > 0)
dependencies.removeIndex(dependencies.size - 1);
return new String[0];
}
Array<Animation> animations = ((SkeletonCacheEntry) sourceCache.get(anim.source)).skeleton.getData().getAnimations();
String[] result = new String[animations.size];
for (int i = 0; i < animations.size; i++) {
Animation a = animations.get(i);
result[i] = a.getName();
}
return result;
}
use of com.esotericsoftware.spine.Animation in project bladecoder-adventure-engine by bladecoder.
the class SpineRenderer method startAnimation.
@Override
public void startAnimation(String id, Tween.Type repeatType, int count, ActionCallback cb) {
SpineAnimationDesc fa = (SpineAnimationDesc) getAnimation(id);
if (fa == null) {
EngineLogger.error("AnimationDesc not found: " + id);
return;
}
if (currentAnimation != null && currentAnimation.disposeWhenPlayed)
disposeSource(currentAnimation.source);
currentAnimation = fa;
currentSource = sourceCache.get(fa.source);
animationCb = cb;
// If the source is not loaded. Load it.
if (currentSource == null || currentSource.refCounter < 1) {
loadSource(fa.source, fa.atlas);
EngineAssetManager.getInstance().finishLoading();
retrieveSource(fa.source, fa.atlas);
currentSource = sourceCache.get(fa.source);
if (currentSource == null) {
EngineLogger.error("Could not load AnimationDesc: " + id);
currentAnimation = null;
return;
}
}
if (repeatType == Tween.Type.SPRITE_DEFINED) {
currentAnimationType = currentAnimation.animationType;
currentCount = currentAnimation.count;
} else {
currentCount = count;
currentAnimationType = repeatType;
}
if (currentAnimationType == Tween.Type.REVERSE) {
// get animation duration
Array<Animation> animations = ((SkeletonCacheEntry) currentSource).skeleton.getData().getAnimations();
for (Animation a : animations) {
if (a.getName().equals(currentAnimation.id)) {
lastAnimationTime = a.getDuration() / currentAnimation.duration - 0.01f;
break;
}
}
} else {
lastAnimationTime = 0f;
}
complete = false;
loopCount = 0;
setCurrentAnimation();
}
Aggregations