LibGdx 2半屏“按钮” [英] LibGdx 2 half screen "buttons"
本文介绍了LibGdx 2半屏“按钮”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(Android)所以我是LibGdx的新手,我正在尝试编写这个chrome dino迷你游戏..当用户触摸屏幕的左侧并且当他做出动作2时我想做动作1触摸屏幕的右侧,我该怎么办?
(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半屏“按钮”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文