1. <legend id='hafjE'><style id='hafjE'><dir id='hafjE'><q id='hafjE'></q></dir></style></legend>

      • <bdo id='hafjE'></bdo><ul id='hafjE'></ul>
      <i id='hafjE'><tr id='hafjE'><dt id='hafjE'><q id='hafjE'><span id='hafjE'><b id='hafjE'><form id='hafjE'><ins id='hafjE'></ins><ul id='hafjE'></ul><sub id='hafjE'></sub></form><legend id='hafjE'></legend><bdo id='hafjE'><pre id='hafjE'><center id='hafjE'></center></pre></bdo></b><th id='hafjE'></th></span></q></dt></tr></i><div id='hafjE'><tfoot id='hafjE'></tfoot><dl id='hafjE'><fieldset id='hafjE'></fieldset></dl></div>

      <small id='hafjE'></small><noframes id='hafjE'>

        <tfoot id='hafjE'></tfoot>
      1. 获取 LIBGDX 中的光标位置

        时间:2023-05-18

        <tfoot id='xepAT'></tfoot>

        <i id='xepAT'><tr id='xepAT'><dt id='xepAT'><q id='xepAT'><span id='xepAT'><b id='xepAT'><form id='xepAT'><ins id='xepAT'></ins><ul id='xepAT'></ul><sub id='xepAT'></sub></form><legend id='xepAT'></legend><bdo id='xepAT'><pre id='xepAT'><center id='xepAT'></center></pre></bdo></b><th id='xepAT'></th></span></q></dt></tr></i><div id='xepAT'><tfoot id='xepAT'></tfoot><dl id='xepAT'><fieldset id='xepAT'></fieldset></dl></div>

          <bdo id='xepAT'></bdo><ul id='xepAT'></ul>
          • <legend id='xepAT'><style id='xepAT'><dir id='xepAT'><q id='xepAT'></q></dir></style></legend>

                <tbody id='xepAT'></tbody>
                1. <small id='xepAT'></small><noframes id='xepAT'>

                2. 本文介绍了获取 LIBGDX 中的光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  如何在 libgdx 中获取光标位置并将其应用于 sprite?像这样?

                  How to get cursor position in libgdx and apply it to sprite? Like this?

                  我希望我的精灵的方向指向屏幕中光标所在的任何位置.我搜索了 libgdx 示例,但找不到任何与此相关的示例.

                  I want my sprite to have the direction pointed wherever my cursor is in the screen.I search libgdx examples but i cant find any examples related to that.

                  推荐答案

                  获取光标位置

                  如果要轮询输入,请使用 Gdx.input.getX()Gdx.input.getY() 获取当前鼠标 x 和 y 坐标.(文档说它只与触摸有关,但代码 看起来它报告原始鼠标值不管按钮状态如何.)

                  Get cursor position

                  If you're polling for input, use Gdx.input.getX() and Gdx.input.getY() to get the current mouse x and y coordinates. (The doc says its only relevant for touch, but the code looks like it reports raw mouse values regardless of button state.)

                  如果您使用的是 InputProcessor,您可以使用以下之一:

                  If you're using an InputProcessor you can use one of:

                  • touchMoved 回调(开启较旧的 libGDX 版本)
                  • mouseMoved 回调(在较新的 libGDX 版本上)
                  • touchMoved callback (on older libGDX versions)
                  • mouseMoved callback (on newer libGDX versions)

                  在没有按下按钮的情况下接收来自鼠标的输入事件.

                  to receive input events from a mouse with no buttons pressed.

                  更新 Vector2 从当前精灵位置指向光标位置.这可以是您的 Sprite 的标题.您需要旋转精灵的标题以匹配此向量.

                  Update a Vector2 that points from the current sprite position to the cursor position. This can be your Sprite's heading. You'll want to rotate the sprite's heading to match this vector.

                  使用 Vector2.angle() 来计算这个向量的角度,并将你的精灵的旋转设置为此.(这是相对于正 X 轴的,所以如果你想要它相对于 Y 轴,你可能需要添加一个常数.)

                  Use Vector2.angle() to compute the angle of this vector, and set your sprite's rotation to this. (This is relative to the positive X axis,so you may need to add a constant if you want it relative to the Y axis.)

                  这篇关于获取 LIBGDX 中的光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 LibGDX 中缩放位图字体 下一篇:渲染和触摸输入之间的 libgdx 坐标系差异

                  相关文章

                  最新文章

                3. <i id='Qoim9'><tr id='Qoim9'><dt id='Qoim9'><q id='Qoim9'><span id='Qoim9'><b id='Qoim9'><form id='Qoim9'><ins id='Qoim9'></ins><ul id='Qoim9'></ul><sub id='Qoim9'></sub></form><legend id='Qoim9'></legend><bdo id='Qoim9'><pre id='Qoim9'><center id='Qoim9'></center></pre></bdo></b><th id='Qoim9'></th></span></q></dt></tr></i><div id='Qoim9'><tfoot id='Qoim9'></tfoot><dl id='Qoim9'><fieldset id='Qoim9'></fieldset></dl></div>

                      <bdo id='Qoim9'></bdo><ul id='Qoim9'></ul>

                    <small id='Qoim9'></small><noframes id='Qoim9'>

                    <legend id='Qoim9'><style id='Qoim9'><dir id='Qoim9'><q id='Qoim9'></q></dir></style></legend>
                    <tfoot id='Qoim9'></tfoot>