Search code examples
javaandroidlibgdx

slide on libGDX


I'm doing the shop screen. Shop has 3 pages. And I wrote the slide code. It works fine on PC but it does not work well on Android.

Video: link

Game is here: link

Codes here (UPDATED):

if(Gdx.input.isTouched()){
     if(Gdx.input.justTouched()){
                touchPX = Gdx.input.getX();
     }
    HOR  += (touchPX - Gdx.input.getX());
    touchPX = Gdx.input.getX();
} 

SB.draw(pokeball, -HOR + 123,123);

Where is the problem and how can i solve ?


Solution

  • I solved the problem with Gdx.input.getDeltaX():

    if(Gdx.input.isTouched()){ 
        HOR -= Gdx.input.getDeltaX();
    } 
    
    SB.draw(pokeball, -HOR + 123,123);
    

    Gdx.input.GetDeltaX() gives the x change so i wasn't need extra codes.