I'm creating a pop out action effect on a window after I click on some button in LibGdx.
May I know, Is there any methods available to scale the actor, in a way that keeping its center position at the center (scales in both direction of x and also both direction of y)?
addAction(sequence(scaleTo(1.3f,1.3f,0.2f),scaleTo(1f,1f,0.2f)));
This is the basic scaling method I used.
↑
O →
But I want something like this:
......↑
← O →
......↓
You need to set actor's origin to its center. First set the size, and then call:
actor.setOrigin(Align.center);
Note, that if your actor is a Table (and classes like Button, ImageButton extend Table), then you need to call:
actor.setTransform(true); // But keep in mind that has a performance impact "because {@link Batch#flush()} must be done before and after the transform"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With