I am making a racing game using Libgdx. I want to touch half of the right side of the screen to speed up, at the same time, without deleting the previous touch point, tap again on the left side of the screen to shoot. I cannot detect later touch points.
I searched and got the Gdx.input.isTouched(int index) method, but cannot determine how to use it. My screen code:
if(Gdx.input.isTouched(0) && world.heroCar.state != HeroCar.HERO_STATE_HIT){ guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (OverlapTester.pointInRectangle(rightScreenBounds, touchPoint.x, touchPoint.y)) { world.heroCar.state = HeroCar.HERO_STATE_FASTRUN; world.heroCar.velocity.y = HeroCar.HERO_STATE_FASTRUN_VELOCITY; } } else { world.heroCar.velocity.y = HeroCar.HERO_RUN_VELOCITY; } if (Gdx.input.isTouched(1)) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (OverlapTester.pointInRectangle(leftScreenBounds, touchPoint.x, touchPoint.y)) { world.shot(); } }
Vishal singh
source share