我正在尝试使用 Action FadeOut 将 Actor 淡出。但是,我发现 no 操作对我的对象根本不起作用。我的类的层次结构是这样的:
Actor -> MoveableObject -> Knight
Stage -> KnightGroup (Group) -> Knight
我的骑士演员的行动根本不起作用。但是,我的 KnightGroup 组的操作有效。这是我的骑士的代码:
public class Knight extends Players {
public Knight() {
setWidth(96);
setHeight(96);
setPosition(100, 90);
//Doesn't work
AlphaAction action = new AlphaAction();
action.setAlpha(0f);
action.setDuration(1f);
addAction(action);
//Doesn't work
addAction(fadeOut(1f));
addAction(Actions.scaleBy(1f, 1f));
}
@Override
public void act(float delta){
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.setColor(getColor().r, getColor().g, getColor().b, getColor().a);
batch.draw(animation[currentState], getX(), getY(), getWidth(), getHeight());
}
}
我一生都无法弄清楚问题所在。(Knight 的父级)中的操作MoveableObject
也不起作用。我最好的猜测是,将演员包裹在这些演员的Group
遗嘱render
中actions
无效。虽然这KnightGroup
是我的代码中非常重要的部分,但我必须进行大量重构才能将其删除。其他人可以阐明这个问题吗?