LibGdx 如何获得 child 组的总舞台轮换?
LibGdx How to get total stage rotation for child of group?
类似于这个问题:
但我想知道是否有办法获取一组 child 的当前旋转而不是位置?
例如:
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?
扩展@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;
}
类似于这个问题:
但我想知道是否有办法获取一组 child 的当前旋转而不是位置?
例如:
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?
扩展@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;
}