I am trying to fade an Actor out using the Action FadeOut. However, I've discovered that the no actions work at all for my objects. The hierarchy of my classes are like this:
Actor -> MoveableObject -> Knight
Stage -> KnightGroup (Group) -> Knight
Actions for my Knight actors do not work at all. However, actions for my KnightGroup group works. Here is the code for my Knight:
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());
}
}
I can't for the life of me figure out what the problem is. Actions in MoveableObject
(the parent of Knight) doesn't work either. My best guess is that wrapping actors in a Group
will render
the actions
of those actors invalid. The KnightGroup
is a pretty crucial part of my code though and I would have to do a lot of refactoring to take it out. Can someone else shed some light on this issue?