Search in sources :

Example 21 with SpriteActor

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

the class SpineSecondaryAnimationAction method run.

@Override
public boolean run(VerbRunner cb) {
    String actorId = animation.getActorId();
    SpriteActor a = (SpriteActor) World.getInstance().getCurrentScene().getActor(actorId, true);
    if (a.getRenderer() instanceof SpineRenderer) {
        SpineRenderer r = (SpineRenderer) a.getRenderer();
        String anim = animation.getAnimationId();
        if (anim.isEmpty())
            anim = null;
        r.setSecondaryAnimation(anim);
    } else {
        EngineLogger.error("SpineSecondaryAnimation: The actor renderer has to be of Spine type.");
    }
    return false;
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) SpineRenderer(com.bladecoder.engine.spine.SpineRenderer)

Example 22 with SpriteActor

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

the class SpineSkinAction method run.

@Override
public boolean run(VerbRunner cb) {
    SpriteActor a = (SpriteActor) actor.getActor();
    if (a instanceof SpriteActor && a.getRenderer() instanceof SpineRenderer) {
        SpineRenderer r = (SpineRenderer) a.getRenderer();
        r.setSkin(skin);
    } else {
        EngineLogger.error("SpineSecondaryAnimation: The actor renderer has to be of Spine type.");
    }
    return false;
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) SpineRenderer(com.bladecoder.engine.spine.SpineRenderer)

Example 23 with SpriteActor

use of com.bladecoder.engine.model.SpriteActor 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 24 with SpriteActor

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

the class PositionAnimAction method run.

@Override
public boolean run(VerbRunner cb) {
    float scale = EngineAssetManager.getInstance().getScale();
    BaseActor a = World.getInstance().getCurrentScene().getActor(actor, true);
    float x = a.getX();
    float y = a.getY();
    if (target != null) {
        BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
        x = target.getX();
        y = target.getY();
        if (target instanceof InteractiveActor) {
            Vector2 refPoint = ((InteractiveActor) target).getRefPoint();
            x += refPoint.x;
            y += refPoint.y;
        }
        if (pos != null) {
            x += pos.x * scale;
            y += pos.y * scale;
        }
    } else if (pos != null) {
        x = pos.x * scale;
        y = pos.y * scale;
    }
    if (speed == 0 || !(a instanceof SpriteActor)) {
        a.setPosition(x, y);
        return false;
    } else {
        // WARNING: only spriteactors support animation
        float s;
        if (mode != null && mode == Mode.SPEED) {
            Vector2 p0 = new Vector2(a.getX(), a.getY());
            s = p0.dst(x, y) / (scale * speed);
        } else {
            s = speed;
        }
        SpritePosTween t = new SpritePosTween();
        t.start((SpriteActor) a, repeat, count, x, y, s, interpolation, wait ? cb : null);
        ((SpriteActor) a).addTween(t);
    }
    return wait;
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) SpritePosTween(com.bladecoder.engine.anim.SpritePosTween)

Example 25 with SpriteActor

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

the class RotateAction method run.

@Override
public boolean run(VerbRunner cb) {
    SpriteActor a = (SpriteActor) World.getInstance().getCurrentScene().getActor(actor, false);
    SpriteRotateTween t = new SpriteRotateTween();
    t.start(a, repeat, count, rotation, speed, interpolation, wait ? cb : null);
    a.addTween(t);
    return wait;
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) SpriteRotateTween(com.bladecoder.engine.anim.SpriteRotateTween)

Aggregations

SpriteActor (com.bladecoder.engine.model.SpriteActor)32 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)16 BaseActor (com.bladecoder.engine.model.BaseActor)12 CharacterActor (com.bladecoder.engine.model.CharacterActor)10 Vector2 (com.badlogic.gdx.math.Vector2)8 Scene (com.bladecoder.engine.model.Scene)7 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)6 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)6 AnchorActor (com.bladecoder.engine.model.AnchorActor)5 TextRenderer (com.bladecoder.engine.model.TextRenderer)5 Verb (com.bladecoder.engine.model.Verb)5 Polygon (com.badlogic.gdx.math.Polygon)4 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)4 Rectangle (com.badlogic.gdx.math.Rectangle)3 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)3 Dialog (com.bladecoder.engine.model.Dialog)3 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)3 SceneLayer (com.bladecoder.engine.model.SceneLayer)3 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)3 World (com.bladecoder.engine.model.World)3