【问题标题】:LibGdx How to get total stage rotation for child of group?LibGdx 如何获得组的孩子的总舞台旋转?
【发布时间】:2015-10-23 01:35:05
【问题描述】:

类似这个问题: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?

【问题讨论】:

  • 你可以总结演员本身和所有父母的所有旋转,直到你到达根。

标签: java rotation libgdx coordinate-transformation


【解决方案1】:

扩展@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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-19
    • 2018-04-28
    • 2019-03-23
    • 2013-08-07
    • 2015-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多