LibGdx如何获得小组儿童的总舞台轮换?

时间:2015-10-23 01:35:05

标签: java rotation libgdx coordinate-transformation

与此问题类似:https://stackoverflow.com/a/23701065

但是我想知道是否有办法让一个小组的孩子而不是位置获得当前的轮换?

例如:

Group g1 = new Group();
Group g2 = new Group();
Actor a = new Actor();
g1.addActor(g2);
g2.addActor(a);
g1.setRotation(90);
g2.setRotation(45);
//How to get `a` actual rotation in reference to stage?

1 个答案:

答案 0 :(得分:0)

要扩展@noone的评论,并将我最​​终得到的内容展开:

我已经使用自己的子类扩展了Group,所以我只添加了以下方法:

/**
 * Returns the total rotation of the parent grouping.
 * Does not include this group's rotation.
 **/
public float getTotalParentRotation()
{
    Group g = this.getParent();
    float rotation = 0.00f;
    while (g!=null) {
        rotation += g.getRotation();
        g = g.getParent();
    }
    return rotation;
}