LibGDX Scene2D: Actions will not work at all for members within groups

I am trying to supplant an actor using Action FadeOut. However, I found that no actions work at all for my objects. The hierarchy of my classes is as follows:

Actor -> MoveableObject -> Knight

Stage -> KnightGroup (Group) -> Knight

The actions of my knight actors do not work at all. However, the actions for my KnightGroup work. 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 understand in my life what the problem is. Actions in MoveableObject(Knight's parent) also do not work. My best guess is that wrapping the actors in these participants Groupwill be render actionsinvalid. KnightGroupis a pretty important part of my code, although I will have to do a lot of refactoring to pull it out. Can someone else shed light on this issue?

+4
1

Actor act(float delta) act(delta) Action Actor. , super.act(delta) Actor, act(delta) Actor.

+6

Source: https://habr.com/ru/post/1528897/


All Articles