libgdx在其Y轴上旋转actor [英] Libgdx rotate an actor on its Y axis
问题描述
我正在尝试在Libgdx中制作卡片翻转动画. Sprite和Actor仅支持顺时针/逆时针旋转. 因此,我认为我可以通过在相机对象中使用旋转"功能来实现. 问题在于它不仅影响演员,而且影响整个舞台.
I'm trying to do a card flip animation in Libgdx. Sprites and Actors support only rotation clockwise/counter-clockwise. So I thought that I can achieve that by using the Rotate function in the camera object. The problem is that it affects the whole stage and not just the actor.
如何在不创建新阶段的情况下实现这种影响?
How can I achieve this affect without creating a new stage?
推荐答案
好吧,您从来没有定义卡片背面的样子,因为演员只是图像;)
Well you have never defined what the back side of a card looks like, since actors are just images ;)
您可以做的是使用两张图像,一幅用于正面,一幅用于背面(起初是不可见的).
What you could do is to use two images, one for the front, one for the back (which is at first invisible).
翻转卡片时,您将添加一个Action,该Action将frontImage的x分量缩放为0,然后将backimage从0缩放为1.
When flipping the card you would add an Action that scales the x-component of the frontImage to 0, and then scales the backimage from 0 to 1.
所以首先,您必须隐藏背景图像
So at first you would have to hide the backimage
cardBack.addAction(Actions.scaleTo(0,1);
然后在翻转时,您可以执行以下操作:
Then when flipping, you could do something like this:
cardFront.addAction(Actions.scaleTo(0,1, DURATION/2));
cardBack.addAction(Actions.delay(DURATION/2), Actions.scaleTo(1,1, DURATION/2));
希望这对您有帮助...:)
Hope this helps... :)
这篇关于libgdx在其Y轴上旋转actor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!