【问题标题】:LibGDX, Need click event in portable application and in Stage, how?LibGDX,在便携式应用程序和舞台中需要点击事件,如何?
【发布时间】:2016-06-01 19:14:33
【问题描述】:

我正在使用 libGDX 创建一个视频游戏,为此我需要有 2 个点击事件,一个在舞台对象上,另一个在窗口上。

当我在我的 init 方法中添加舞台时:

Gdx.input.setInputProcessor(stage);

从便携应用继承的onClick事件被禁用...

我的问题有解决方案吗?

非常感谢!

【问题讨论】:

    标签: java onclick libgdx stage


    【解决方案1】:

    如果您希望舞台优先,请使用Gdx.input.setInputProcessor(new InputMultiplexer(otherInputProcessor, stage)); 交换两者的顺序。

    【讨论】:

      【解决方案2】:

      解决办法

      private InputProcessor inpOne;
      

      在init()方法中:

      inpOne = new InputProcessor() {
                  ...
          public boolean touchUp(int screenX, int screenY, int pointer, int button) {
                      // TODO Auto-generated method stub
                      System.out.println("Hello2");
                      return false;
                  }
                 ...
      };
      Gdx.input.setInputProcessor(new InputMultiplexer(stage, inpOne));
      

      newInputMultiplexer的第一个参数是HighestPriority事件!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-27
        • 1970-01-01
        • 2011-02-09
        • 2020-02-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多