Search in sources :

Example 11 with AnimationRenderer

use of com.bladecoder.engine.model.AnimationRenderer in project bladecoder-adventure-engine by bladecoder.

the class PickUpAction method run.

@Override
public boolean run(VerbRunner cb) {
    Scene scn = this.actor.getScene();
    InteractiveActor actor = (InteractiveActor) scn.getActor(this.actor.getActorId(), false);
    if (actor == null) {
        EngineLogger.error("PickUpAction - Actor not found:" + this.actor.getActorId());
        return false;
    }
    scn.removeActor(actor);
    if (actor instanceof SpriteActor) {
        SpriteActor a = (SpriteActor) actor;
        if (scn != World.getInstance().getCurrentScene() && World.getInstance().getCachedScene(scn.getId()) == null) {
            a.loadAssets();
            EngineAssetManager.getInstance().finishLoading();
            a.retrieveAssets();
        }
        if (a.getRenderer() instanceof AnimationRenderer) {
            if (animation != null)
                a.startAnimation(animation, null);
            else if (((AnimationRenderer) a.getRenderer()).getAnimations().get(a.getId() + ".inventory") != null)
                a.startAnimation(a.getId() + ".inventory", null);
        }
        World.getInstance().getInventory().addItem(a);
    }
    return false;
}
Also used : InteractiveActor(com.bladecoder.engine.model.InteractiveActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) Scene(com.bladecoder.engine.model.Scene) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 12 with AnimationRenderer

use of com.bladecoder.engine.model.AnimationRenderer in project bladecoder-adventure-engine by bladecoder.

the class AnimationAction method run.

@Override
public boolean run(VerbRunner cb) {
    // EngineLogger.debug(MessageFormat.format("ANIMATION_ACTION: {0}.{1}", animation.getActorId(), animation.getAnimationId()));
    String actorId = animation.getActorId();
    SpriteActor a = (SpriteActor) World.getInstance().getCurrentScene().getActor(actorId, true);
    String anim = animation.getAnimationId();
    if (keepDirection) {
        String c = ((AnimationRenderer) a.getRenderer()).getCurrentAnimationId();
        if (anim.endsWith(AnimationRenderer.LEFT) && c.endsWith(AnimationRenderer.RIGHT) || anim.endsWith(AnimationRenderer.RIGHT) && c.endsWith(AnimationRenderer.LEFT)) {
            anim = AnimationRenderer.getFlipId(anim);
        }
    }
    a.startAnimation(anim, repeat, count, wait ? cb : null);
    return wait;
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Aggregations

AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)12 SpriteActor (com.bladecoder.engine.model.SpriteActor)6 AnimationDesc (com.bladecoder.engine.anim.AnimationDesc)4 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)2 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)2 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)2 Scene (com.bladecoder.engine.model.Scene)2 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)2 Color (com.badlogic.gdx.graphics.Color)1 Vector2 (com.badlogic.gdx.math.Vector2)1 AtlasAnimationDesc (com.bladecoder.engine.anim.AtlasAnimationDesc)1 SpineAnimationDesc (com.bladecoder.engine.anim.SpineAnimationDesc)1 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)1 BaseActor (com.bladecoder.engine.model.BaseActor)1 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)1 VerbRunner (com.bladecoder.engine.model.VerbRunner)1 UndoDeleteAnimation (com.bladecoder.engineeditor.undo.UndoDeleteAnimation)1 ArrayList (java.util.ArrayList)1