如何处理多个触摸输入 if(Gdx.input.isTouched()){ //向右移动触摸屏 如果(touchPos.x>=310&&touchPos.x=770&&touchPos.y=70&&touchPos.x=770&&touchPos.y=1630&&touchPos.x=740&&touchPos.y

如何处理多个触摸输入 if(Gdx.input.isTouched()){ //向右移动触摸屏 如果(touchPos.x>=310&&touchPos.x=770&&touchPos.y=70&&touchPos.x=770&&touchPos.y=1630&&touchPos.x=740&&touchPos.y,input,libgdx,Input,Libgdx,看起来您正在检查触摸是否在正方形内。您可以放置一些矩形,而不是检查触摸是否在所有这些坐标的边界内 或者更好的是,使用Scene2d添加按钮。这将有助于更好、更可靠的输入控制。 如果你不想让别人看到,你可以制作隐形按钮 if(Gdx.input.isTouched()) { //moving right touchscreen if(touchPos.x >= 310 && touchPos.x <= 445

看起来您正在检查触摸是否在正方形内。您可以放置一些矩形,而不是检查触摸是否在所有这些坐标的边界内

或者更好的是,使用Scene2d添加按钮。这将有助于更好、更可靠的输入控制。 如果你不想让别人看到,你可以制作隐形按钮

        if(Gdx.input.isTouched()) {      
        //moving right touchscreen
        if(touchPos.x >= 310 && touchPos.x <= 445 && touchPos.y >= 770  &&touchPos.y <= 870 )
            man.b2body.applyLinearImpulse(new Vector2(0.1f, 0), man.b2body.getWorldCenter(), true);
        //moving left touchscreen
        if(touchPos.x >= 70 && touchPos.x <= 220 && touchPos.y >= 770  &&touchPos.y <= 870 )
            man.b2body.applyLinearImpulse(new Vector2(-0.1f, 0), man.b2body.getWorldCenter(), true);
        if(touchPos.x >=1630  && touchPos.x <= 1815 && touchPos.y >= 740  &&touchPos.y <=  935 && man.b2body.getPosition().y <=0.22)
            man.b2body.applyLinearImpulse(new Vector2(0, 4f), man.b2body.getWorldCenter(), true);