2016-05-30 23 views
2

我曾嘗試在Actor上使用InputListener,但看起來touchUp並未被調用。其他任何方法都適用於我。Scene2d:InputListener不會調用touchUp

stage = new Stage(new ScreenViewport()); 

Widget actor = new Widget(); 
actor.setFillParent(true); 
actor.addListener(new InputListener() { 
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) { 
     Gdx.app.log("", ""); 
    } 
}); 
stage.addActor(actor); 
Gdx.input.setInputProcessor(stage); 

回答

2
stage = new Stage(new ScreenViewport()); 

    Widget actor = new Widget(); 
    actor.setFillParent(true); 
    actor.addListener(new InputListener() { 

     @Override 
     public void touchDown(InputEvent event, float x, float y, int pointer, int button) { 
      return true; 
     } 

     @Override 
     public void touchUp(InputEvent event, float x, float y, int pointer, int button) { 
      Gdx.app.log("", ""); 
     } 
    }); 
    stage.addActor(actor); 


    Gdx.input.setInputProcessor(stage);