List of usage examples for com.badlogic.gdx Input isTouched
public boolean isTouched();
From source file:com.digitale.screens.GameLoop.java
License:Open Source License
@Override public void update(float delta) { simulation.update(delta);// w w w.j a va 2 s .c o m droneOrbitAngle = droneOrbitAngle + 1; // detect and set black fade in // cameraHorizAngle= (int) (Ship.yawAngle/Math.PI); Input input = Gdx.app.getInput(); androidVersion = Gdx.app.getVersion(); float turnSpeed = .8f * simulation.gameSpeed; // System.out.println("accelx " + input.getAccelerometerX() + " accly " // + input.getAccelerometerY()); if (Ship.STATUS == 1 && Stardust3d.stationScreen == 0) { // only check accelerometer on android platforms if (androidVersion != 0) { accellerometer(input); } checkShipContols(input, turnSpeed, delta); // check rotations haven't gone too far rectifyShipAngles(); // set ship rotation (Quat) yaw and pitch from Euler Ship.shipRot.setEulerAngles(Ship.yawAngle, Ship.pitchAngle, 0); Vector3 heading = new Vector3(0, 0, -1); Ship.shipRot.transform(heading); Simulation.ship.heading = heading; // add heading vector to ship position Ship.position.add(heading.mul(Ship.SHIP_VELOCITY * delta)); rectifyTouchCoords(input); if (input.isTouched()) { menuSelected = false; if (Stardust3d.DEEPDEBUG) System.out.println("x=" + touch_x + " y=" + touch_y); // thumbcontrol(); rightmenu(); throttle(delta); leftmenu(); if (!menuSelected) { checkForSelection(); } } } if (Ship.STATUS == 0 && Stardust3d.stationScreen == 0) { rectifyTouchCoords(input); if (input.isTouched()) { if (Stardust3d.DEBUG) System.out.println("x=" + touch_x + " y=" + touch_y); thumbcontrol(); leftmenu(); dockedrightmenu(); } } }
From source file:com.digitale.screens.GameLoop.java
License:Open Source License
/** * @param input//w w w. j a v a 2 s . c o m * set touch co-ords so they match screen co-ords */ private void rectifyTouchCoords(Input input) { screenScaleX = Gdx.app.getGraphics().getWidth() / 800f; screenScaleY = Gdx.app.getGraphics().getHeight() / 480f; camera.unproject(GameLoop.touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); int x = input.getX(); int y = input.getY(); if (input.justTouched()) { touch_x = input.getX(); touch_y = input.getY(); } if (input.isTouched()) { x += input.getX() - touch_x; y += touch_y - input.getY(); touch_x = input.getX(); // x; touch_y = input.getY(); // y; } touch_x = touch_x / screenScaleX; touch_y = touch_y / screenScaleY; if (Stardust3d.DEEPDEBUG) System.out.println("Width:" + Gdx.app.getGraphics().getWidth() + "Height:" + Gdx.app.getGraphics().getHeight() + "xscale:" + screenScaleX + " yscale:" + screenScaleY); }