私は2つの長方形AとBを持っています。私がしなければならないことは、最初の長方形(A)が押されると、2番目の長方形(B)は3秒間クリックできなくなり、その逆も同様です。また、長方形のいずれかが押された場合、ユーザーが画面をタッチアップした場合にのみ、別の長方形をクリックできます。つまり、両方の長方形を 1 回のタッチでクリックできないようにする必要があります。
私は次のようにやっています:
boolean leftleftRectBool = false,rightRectBool = false;
long scanningTime = System.currentTimeMillis()+3000;//in constructor
camera.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
if(Gdx.input.isTouched())
{
if (leftThumbRectangle.contains(touchPoint.x, touchPoint.y)) {
if (scanningTime > System.currentTimeMillis()) {
leftRectBool = false;
scanningTimeStart = true;
} else {
scanningTime = 0;
scanningTimeStart = false;
leftRectBool = true;
}
}
if(rightThumbRectangle.contains(touchPoint.x, touchPoint.y)) {
if (scanningTime > System.currentTimeMillis()) {
rightRectBool = false;
scanningTimeStart = true;
} else {
scanningTime = 0;
scanningTimeStart = false;
rightRectBool = true;
}
}
else {
scanningTime = System.currentTimeMillis() + 3000;
}
if(lefttRectBool && lefttRectBool)
{
// some thing happen
}
そして draw() で
if(lefttRectBool)
{
//some thing haapens
}
else if(rightRectBool)
{
//some things happen
}