use of com.bladecoder.engine.anim.AtlasAnimationDesc in project bladecoder-adventure-engine by bladecoder.
the class EditAnimationDialog method inputsToModel.
@Override
protected void inputsToModel(boolean create) {
String sourceStr = source.getText();
AnimationRenderer renderer = (AnimationRenderer) parent.getRenderer();
if (create) {
if (renderer instanceof SpineRenderer) {
e = new SpineAnimationDesc();
if (spineAtlasExists(sourceStr)) {
((SpineAnimationDesc) e).atlas = null;
setVisible(atlas, false);
} else {
if (!atlas.isVisible()) {
setVisible(atlas, true);
}
((SpineAnimationDesc) e).atlas = atlas.getText();
}
} else if (renderer instanceof AtlasRenderer) {
e = new AtlasAnimationDesc();
} else {
e = new AnimationDesc();
}
} else {
HashMap<String, AnimationDesc> animations = renderer.getAnimations();
animations.remove(e.id);
if (e.id.equals(renderer.getInitAnimation()))
renderer.setInitAnimation(null);
}
e.id = id.getText();
e.sound = sound.getText();
e.source = sourceStr;
e.count = Integer.parseInt(count.getText());
e.preload = Boolean.parseBoolean(preload.getText());
e.disposeWhenPlayed = Boolean.parseBoolean(dispose.getText());
e.animationType = Type.valueOf(repeat.getText());
e.inD = Param.parseVector2(in.getText());
e.outD = Param.parseVector2(out.getText());
e.duration = Float.parseFloat(speed.getText());
((AnimationRenderer) parent.getRenderer()).addAnimation(e);
if (renderer instanceof ImageRenderer && Boolean.parseBoolean(localizable.getText()) && e.source != null && e.source.length() > 0) {
e.source = I18N.PREFIX + e.source;
}
if (renderer.getInitAnimation() == null)
renderer.setInitAnimation(e.id);
// TODO UNDO OP
// UndoOp undoOp = new UndoAddElement(doc, e);
// Ctx.project.getUndoStack().add(undoOp);
Ctx.project.setModified();
}
use of com.bladecoder.engine.anim.AtlasAnimationDesc in project bladecoder-adventure-engine by bladecoder.
the class EditAnimationDialog method setSource.
private void setSource() {
AnimationDesc anim = null;
ActorRenderer renderer = parent.getRenderer();
String sourceStr = source.getText();
if (renderer instanceof SpineRenderer) {
anim = new SpineAnimationDesc();
if (spineAtlasExists(sourceStr)) {
((SpineAnimationDesc) anim).atlas = null;
setVisible(atlas, false);
} else {
if (!atlas.isVisible()) {
setVisible(atlas, true);
}
((SpineAnimationDesc) anim).atlas = atlas.getText();
}
} else if (renderer instanceof AtlasRenderer) {
anim = new AtlasAnimationDesc();
} else {
anim = new AnimationDesc();
}
anim.source = sourceStr;
anim.count = Tween.INFINITY;
anim.preload = true;
anim.disposeWhenPlayed = false;
if (renderer instanceof SpineRenderer) {
spriteWidget.setSource(Project.SPINE_RENDERER_STRING, anim);
} else if (renderer instanceof AtlasRenderer) {
spriteWidget.setSource(Project.ATLAS_RENDERER_STRING, anim);
} else if (renderer instanceof ImageRenderer) {
spriteWidget.setSource(Project.IMAGE_RENDERER_STRING, anim);
} else if (renderer instanceof Sprite3DRenderer) {
spriteWidget.setSource(Project.S3D_RENDERER_STRING, anim);
}
}
use of com.bladecoder.engine.anim.AtlasAnimationDesc 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