use of com.bladecoder.engine.anim.FATween in project bladecoder-adventure-engine by bladecoder.
the class AtlasRenderer method startAnimation.
@Override
public void startAnimation(String id, Tween.Type repeatType, int count, ActionCallback cb) {
if (id == null)
id = initAnimation;
AtlasAnimationDesc fa = (AtlasAnimationDesc) getAnimation(id);
if (fa == null) {
EngineLogger.error("AnimationDesc not found: " + id);
return;
}
if (currentAnimation != null && currentAnimation.disposeWhenPlayed) {
disposeSource(currentAnimation.source);
((AtlasAnimationDesc) currentAnimation).regions = null;
}
currentAnimation = fa;
// If the source is not loaded. Load it.
if (fa.regions == null) {
retrieveFA(fa);
if (fa.regions == null || fa.regions.size == 0) {
EngineLogger.error(currentAnimation.id + " has no regions in ATLAS " + currentAnimation.source);
fanims.remove(currentAnimation.id);
}
}
if (fa.regions.size == 1 || fa.duration == 0.0) {
setFrame(0);
computeBbox();
if (cb != null) {
ActionCallbackQueue.add(cb);
}
return;
}
if (repeatType == Tween.Type.SPRITE_DEFINED) {
repeatType = currentAnimation.animationType;
count = currentAnimation.count;
}
faTween = new FATween();
faTween.start(this, repeatType, count, currentAnimation.duration, cb);
if (repeatType == Tween.Type.REVERSE)
setFrame(getNumFrames() - 1);
else
setFrame(0);
computeBbox();
}
Aggregations