java - libgdx touchup 和 touchdragged 没有被调用,但是 touchdown 是

标签 java input libgdx touchscreen

我有一个 Actor 在舞台上,虽然被击中,并且被称为触地得分,但没有被称为触地得分和触地得分。有什么问题吗?

............
   stage = new Stage(0, 0, true);
   Gdx.input.setInputProcessor(stage);
...........

   @Override
   public Actor hit(float arg_x, float arg_y) {
      if ((arg_x > this.location.x) && (arg_x < (this.location.x + 40)) && (arg_y >     this.location.y) &&    (arg_y < (this.location.y + 40))) {
            Gdx.app.log("Tile", "hit char = " + this.GetLetter());
            return this;
         }
      return null;
   }

   @Override
   public boolean touchDown(float arg_x, float arg_y, int arg2) {
      Gdx.app.log("Tile", "down char = " + this.GetLetter());
      return false;
   }

   @Override
   public void touchDragged(float arg_x, float arg_y, int arg2) {
      Gdx.app.log("Tile", "tile dragged");
   }

   @Override
   public void touchUp(float arg_x, float arg_y, int arg2) {
      Gdx.app.log("Tile", "touchUp");
   }

最佳答案

我在另一个论坛上找到了答案。

  public boolean touchDown(float arg_x, float arg_y, int arg2) {
      Gdx.app.log("Tile", "down char = " + this.GetLetter());
      return false;
  }

应该是

  public boolean touchDown(float arg_x, float arg_y, int arg2) {
      Gdx.app.log("Tile", "down char = " + this.GetLetter());
      return true;
  }

也就是说,它应该返回 true 而不是 false。然后其他方法将在适当的时候被调用。

关于java - libgdx touchup 和 touchdragged 没有被调用,但是 touchdown 是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9856291/

相关文章:

java - WebView 不应在浏览器中打开链接

Javafx)应用程序正在泄漏内存

java - Spring - 在 Spring 项目中包含本身使用 Spring 的 jar 的方法

javascript - val() 函数给出控制台错误

html - 不要在一个特定的输入上包含 css 样式

jquery - 如果使用 jQuery 输入为空,则禁用提交按钮

java - Java中如何限制Hangman的猜测次数

java - libgdx 库的多态性错误

java - 设置 Actor 监听 LibGDX 中的按钮点击

java - 在 LibGDX 中使用 Tiled 时出现黑屏