【问题标题】:libgdx touchup and touchdragged not being called, but touchdown islibgdx touchup 和 touchdragged 没有被调用,但是 touchdown 是
【发布时间】:2012-03-24 22:41:55
【问题描述】:

我有一个演员在舞台上,虽然被击中和触地得分被调用,但触地得分和触地拖拽却没有。有什么想法吗?

............
   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");
   }

【问题讨论】:

    标签: java input libgdx touchscreen


    【解决方案1】:

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

      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。然后在适当的时候调用其他方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 2014-03-20
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      相关资源
      最近更新 更多