(Android)所以我是 LibGdx 的新手,我正在尝试编写这个 chrome dino 迷你游戏.我想在用户触摸屏幕左侧时执行操作 1,并在用户触摸屏幕左侧时执行操作 2触摸屏幕右侧,怎么办?
(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 2 when he touch the right hand side of the screen, how can I do it?
您可以通过在游戏循环中的某处使用以下代码来检测被触摸的一侧:
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
}
}
这篇关于LibGdx 2 半屏“按钮"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!