2017-08-06 106 views
0

我是遊戲編程的新手,對libGDX更是如此。如果有人能看到這個問題,我將不勝感激。如何在按下按鈕時使Gdx.input.istouched返回false?

簡而言之,我現在正在做一個飛揚的鳥類比賽。我使用Gdx.input.istouched來檢查屏幕上的任何點是否被觸摸。如果是這樣,那麼代碼的其餘部分將調用bird.jump()。這很好,直到我添加了一個暫停按鈕。現在,在按鈕可以暫停遊戲之前,鳥跳了。當我按下暫停按鈕時,如何讓遊戲暫停並且沒有鳥跳躍?

您可以查看我的代碼,如果你願意,我正在打開它無論如何來源。這是我的code.

+0

您應該閱讀提問問題指南,特別是如何提供如何創建最小,完整和可驗證示例。你也應該在你的問題中包含相關的代碼。 – alexi2

+0

不要使用justTouched。使用InputListener。 – Tenfour04

回答

1

使用InputProcessor並覆蓋監聽器的方法touchDown(..)。此外,您需要將該偵聽器與您的hud階段InputProcessor複用。

InputMultiplexer inputMultiplexer=new InputMultiplexer(); 
    inputMultiplexer.addProcessor(new InputAdapter() { 

     @Override 
     public boolean touchDown(int screenX, int screenY, int pointer, int button) { 

      bird.jump(); 
      return super.touchDown(screenX, screenY, pointer, button); 
     } 
    }); 

inputMultiplexer.addProcessor(scoreAndButton.stage); 
Gdx.input.setInputProcessor(inputMultiplexer); 
相關問題