2014-12-25 124 views
0

您好我正在嘗試使紋理垂直滾動,我無法獲得正確的行爲。LibGDX:垂直滾動紋理

這裏是我的代碼:

if (Gdx.input.isTouched()) { 
     if (startingy == 0) { 
      startingy = (Gdx.input.getY()) 
        /(Gdx.graphics.getHeight()/MainGame.HEIGHT); 
     } 
     else if(getstart){ 
      startingy = startingy-scroll; 
      getstart = false; 

     } 
     scroll = (Gdx.input.getY()) 
       /(Gdx.graphics.getHeight()/MainGame.HEIGHT); 

     if (startingy -scroll < 0) { 
      startingy = 0; 
      scroll = 0; 
     } 
     if (startingy > img.getHeight()) { 
      startingy = img.getHeight(); 
     } 
    } else { 
     getstart = true; 
    } 

任何幫助,將不勝感激,三江源!

回答

1

爲什麼不讓自己更容易,並使用InputListenertouchDragged方法。 https://github.com/libgdx/libgdx/wiki/Event-handling

當你已經通過由InputListener類,你可以簡單地將它設置爲監聽器:

Gdx.input.setInputProcesser(myProcesser);