没有调用libgdx touchup和touchdragged,但是触地得分

时间:2012-03-24 22:41:56

标签: java input libgdx touchscreen

我在舞台上有一个演员虽然被击中,但正在调用触地得分,touchup和touchdragged则没有。关于什么是错的任何想法?

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

1 个答案:

答案 0 :(得分:9)

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

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