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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations