如何获得儿童演员中某个点的世界坐标?

编程入门 行业动态 更新时间:2024-10-27 07:22:24
本文介绍了如何获得儿童演员中某个点的世界坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有Group个对象,这些对象由其他Group个对象组成,最后又由Actor个对象组成.现在,当组和角色旋转,偏移和缩放时,世界"中或相对于根节点的坐标将发生变化.如何获取演员局部空间中某个点的世界坐标?

I have Group objects that consist of other Group objects, that finally consist of Actor objects. Now, when the groups and actors are rotated, offset and scaled, the coordinates in the "world", or in relation to the root node change. How do I get the world coordinates of a point in an actor's local space?

为进一步说明,这是我想要的示例:

To illustrate a bit more, here's an example of what I want:

Group parentGroup; Actor childInGroup; ... parentGroup.addActor(childInGroup); childInGroup.setPosition(10f, 15f); childInGroup.setRotation(45f); // Get the childInGroup's position in the world float childWorldPosX = ...; // This is what I want to know float childWorldPosY = ...; // ... and this.

推荐答案

您可以使用Groups的层次结构中仅高出一步,并且Actors,或直接使用 Actor.localToStageCoordinates() 直接获取"stage-global"坐标.在这种情况下,libGDX将递归地应用localToParentCoordinates,直到它到达舞台的根元素为止.

You can either use Actor.localToParentCoordinates() if you want to go just one step higher in your hierarchy of Groups and Actors, or directly use Actor.localToStageCoordinates() to get the "stage-global" coordinates directly. In this case, libGDX will recursively apply the localToParentCoordinates until it hits the root element of your stage.

更多推荐

如何获得儿童演员中某个点的世界坐标?

本文发布于:2023-11-25 03:50:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:坐标   如何获得   演员   儿童   世界

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!