LibGdx 2 half screen “buttons”

前端 未结 1 515
Happy的楠姐
Happy的楠姐 2021-01-25 09:51

(Android) So I\'m new to LibGdx and I\'m trying to code this chrome dino mini game.. I want to make action 1 when the user touch the left hand side of the screen and make action

1条回答
  •  孤街浪徒
    2021-01-25 10:34

    You can detect the side being touched by using the following code somewhere inside your game loop:

    if (Gdx.input.isTouched()) {
        if (Gdx.input.getX() > Gdx.graphics.getWidth() / 2){
            //touched right
        } else {
            //touchde left
        }
    }
    

    0 讨论(0)
提交回复
热议问题