If you use Actor in your code, you can use these two actions that I wrote:
public class MyActions {
public static Action flipOut(final float x, final float width, final float duration) {
return new Action() {
float left = duration;
@Override
public boolean act(float delta) {
left -= delta;
if (left <= 0) {
actor.setX(x + (width / 2));
actor.setWidth(0);
return true;
}
float tmpWidth = width * (left / duration);
actor.setX(x + ((width / 2) - (tmpWidth / 2)));
actor.setWidth(tmpWidth);
return false;
}
};
}
public static Action flipIn(final float x, final float width, final float duration) {
return new Action() {
float done = 0;
@Override
public boolean act(float delta) {
done += delta;
if (done >= duration) {
actor.setX(x);
actor.setWidth(width);
return true;
}
float tmpWidth = width * (done / duration);
actor.setX(x + ((width / 2) - (tmpWidth / 2)));
actor.setWidth(tmpWidth);
return false;
}
};
}
}
You can combine these actions with
myActor.addAction(
new SequenceAction(
MyActions.flipOut(x, width, duration),
MyActions.flipIn(x, width, duration)));
If you want your card to have different sides, you would need to perform an average action to switch the actorβs image.
, , :
SequenceAction action = new SequenceAction(
new ParallelAction(
Actions.scaleTo(0, 1, duration),
Actions.moveBy(width / 2, 0, duration)),
new ParallelAction(
Actions.scaleTo(1, 1, duration),
Actions.moveBy(-width / 2, 0, duration)));