2017-03-08 112 views

回答

1

階段都有你的屏幕大小,因此,你可以在舞臺上添加輸入監聽

stage.addListener(new InputListener(){ 
    @Override 
     public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { 
      //you action here 
      stage.removeActor(dialog); 
      return true; 
     } 

}); 

對話必須是你的類的領域,當然

+0

'階段。 removeActor'不存在 – Lynob

+0

是的,這是我的錯誤。對話框不屬於這個階段。用'dialog.hide()改變'stage.removeActor'' – danielleontiev

+0

這是做到這一點的方法之一,它的缺點是它關閉了觸摸對話框,即使觸摸位於對話框邊框內,也不存在一個更好的選項,只有當用戶觸摸對話邊界之外的某個地方時纔會關閉對話框。 – Lynob

相關問題