• <small id='R6oUW'></small><noframes id='R6oUW'>

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

      1. <tfoot id='R6oUW'></tfoot>

        <legend id='R6oUW'><style id='R6oUW'><dir id='R6oUW'><q id='R6oUW'></q></dir></style></legend>

        Libgdx - 检查一个键是否被按住?

        时间:2023-05-19
        <tfoot id='inEWh'></tfoot>
          <bdo id='inEWh'></bdo><ul id='inEWh'></ul>

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

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

                    <tbody id='inEWh'></tbody>

                • 本文介绍了Libgdx - 检查一个键是否被按住?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用 java libgdx 游戏库,我很好奇我是否可以判断一个键是否被按住,而不是按下并松开.

                  I'm using the java libgdx game library and im curious if I can tell if a key is being HELD, not pressed and let go.

                  我需要知道这一点,因为如果按下它,我将播放一个较短的 mp3 文件,如果按住它,我将播放一个较长的文件.

                  I need to know this because I'm going to play a shorter mp3 file if it is just pressed and a longer one if it is held.

                  推荐答案

                  是的,您可以通过 Gdx.input.isKeyPressed(Input.Keys.XXX) 或通过实现 InputProcessor.

                  Yes, you can easily check they either via Gdx.input.isKeyPressed(Input.Keys.XXX) or by implementing an InputProcessor.

                  public class MyInputProcessor implements InputProcessor {
                  
                      public boolean keyPressed;
                  
                      @Override
                      public boolean keyDown(int keycode) {
                          if (keycode == Input.Keys.XXX) {
                              keyPressed = true;
                          }
                  
                          return false;
                      }
                  
                      @Override
                      public boolean keyUp(int keycode) {
                          if (keycode == Input.Keys.XXX) {
                              keyPressed = false;
                          }
                  
                          return false;
                      }
                  }
                  

                  并像这样使用它:

                  MyInputProcessor processor = new MyInputProcessor();
                  Gdx.input.setInputProcessor(processor);
                  
                  ...
                  
                  if (processor.keyPressed) {
                      // do some stuff
                  }
                  

                  您可以在此处了解更多信息.

                  You can read more about that here.

                  这篇关于Libgdx - 检查一个键是否被按住?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java - LibGDX - isKeyPressed 和 isKeyJustPressed 有什么区别 下一篇:Libgdx 3D 纹理透明度

                  相关文章

                  最新文章

                • <tfoot id='ZScAf'></tfoot>

                  • <bdo id='ZScAf'></bdo><ul id='ZScAf'></ul>

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

                    <legend id='ZScAf'><style id='ZScAf'><dir id='ZScAf'><q id='ZScAf'></q></dir></style></legend>