Libgdx rotate an actor on its Y axis

最后都变了- 提交于 2019-12-11 14:52:49

问题


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?


回答1:


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).

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... :)



来源:https://stackoverflow.com/questions/22436674/libgdx-rotate-an-actor-on-its-y-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!