# LibGDX: Why won't certain actions work on my Actor?

In my GameClass, I called the Stage.act and Stage.draw methods in the right order accordingly.

I have actions set up so that the actor fades in/fades out, bounces down/up, and also rotate, like so:

Label.LabelStyle font = new Label.LabelStyle(new BitmapFont(), Color.BLACK);

Table table = new Table();
table.center();
table.setFillParent(true);

Label playLabel = new Label("Text", font);

Action size = new SequenceAction(Actions.sizeBy(-20,-30,1), Actions.sizeBy(10,20,1));
Action rotate = new SequenceAction(Actions.rotateBy(20), Actions.rotateBy(-40));

ParallelAction pa = new ParallelAction(fade, size, rotate);

table.row();



The thing is, everything works except for the rotate method.

Similarly, I have similar problem when I use an Actor with Texture regions.

This is an example from another class.

public ReadyText () {
cam = GameClass.cam;
viewport = GameClass.viewport;
cam.setToOrtho(true, viewport.getWorldWidth(), viewport.getWorldHeight());
this.setX(28);
this.setY(165);
this.setWidth(80);
this.setHeight(30);

Action rotate = Actions.sequence(Actions.rotateBy(80, 1), Actions.rotateBy(-90,1));
Action resize = Actions.sequence(Actions.sizeBy(10, 5,1), Actions.sizeBy(-10,-5,1));

ParallelAction pa = new ParallelAction(rotate, resize);

}

@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);

batch = GameClass.batch;
batch.setProjectionMatrix(GameClass.cam.combined);
batch.draw(region, this.getX(), this.getY(), this.getWidth(), this.getHeight());

}


In this example, the "sizeBy" method works fine. But for some reason, it will not rotate. I commented out the "fade in/fade out" line; it also wasn't working either.

I know people will usually use an Image Actor instead, which makes sense, but I don't think it explains why the rotation won't work, or at the very least, why the Label didn't rotate either.

## You need to draw you actor with a method that handle rotation

void draw(TextureRegion region,
float x,
float y,
float originX,
float originY,
float width,
float height,
float scaleX,
float scaleY,
float rotation)


And for alpha actions: (this myActor draw method)

batch.begin();

// Store old batch alpha
temp = batch.getColor();

// Set new alpha to the batch
batch.setColor(new Color(temp.r, temp.g, temp.b, actorAlpha));

batch.draw(texture, getX(), getY(), getOriginX(), getOriginY(), texture.getRegionWidth(), texture.getRegionHeight(), 1, 1, getRotation());

// Restore old batch color
batch.setColor(temp);

batch.end();


Where temp is a Color.

• Hmm okay I see now. What about the fade method? Does that involve using the parentAlpha or something? – Erick Adam Jan 29 '18 at 17:24
• Exactly. You have to use parent alpha. You can even set the batch alpha to actor.alpha before drawing it and then set back the batch alpha to his old value before drawing other things. – Sebastien Servouze Jan 29 '18 at 17:55
• I managed to get the alpha and scale working. But I'm confused about the fade. How do I use the parentAlpha? I've seen some posts saying that it needs to be multiplied to some other alpha. I do't get it. – Erick Adam Jan 29 '18 at 22:20
• I edited my post so to implement it – Sebastien Servouze Jan 29 '18 at 22:34