List of usage examples for com.badlogic.gdx Input getAzimuth
public float getAzimuth();
From source file:com.davidykay.shootout.screens.GameLoop.java
License:Apache License
@Override public void update(Application app) { simulation.update(app.getGraphics().getDeltaTime()); Input input = app.getInput(); final boolean ACCELEROMETER_STEERING = false; if (ACCELEROMETER_STEERING) { if (input.getAccelerometerY() < 0) simulation.moveShipLeft(app.getGraphics().getDeltaTime(), Math.abs(input.getAccelerometerY()) / 10); else/* ww w.java 2 s . co m*/ simulation.moveShipRight(app.getGraphics().getDeltaTime(), Math.abs(input.getAccelerometerY()) / 10); } if (input.isKeyPressed(Keys.DPAD_LEFT)) simulation.moveShipLeft(app.getGraphics().getDeltaTime(), 0.5f); if (input.isKeyPressed(Keys.DPAD_RIGHT)) simulation.moveShipRight(app.getGraphics().getDeltaTime(), 0.5f); if (input.justTouched()) { final float x = input.getX(); final float y = input.getY(); Vector3 nearVector = new Vector3(x, y, 0); Vector3 farVector = new Vector3(x, y, 1); renderer.unproject(nearVector); renderer.unproject(farVector); /** Vector tracing between the near plane and the far plane **/ Vector3 inVector = new Vector3(nearVector); final Plane gamePlane = new Plane(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)); Ray pickRay = renderer.getCamera().getPickRay(x, y); Vector3 intersection = new Vector3(); Vector3 finalVector; if (FLAT_MODE) { // Flat Mode if (Intersector.intersectRayPlane(pickRay, gamePlane, intersection)) { finalVector = new Vector3(intersection); if (finalVector.equals(nearVector)) { Gdx.app.log(TAG, String.format("Near Vector! finalVector:(%s)", finalVector.toString())); } else { Gdx.app.log(TAG, String.format("INTERSECTION! finalVector:(%s)", finalVector.toString())); } } else { Gdx.app.log(TAG, String.format("NO INTERSECTION. nearVector:(%s)", nearVector.toString())); finalVector = new Vector3(nearVector); } } else { // 3D Mode finalVector = new Vector3(nearVector); //for (Alien alien : aliens) { // if ( // Intersector.intersectRayPlane( // pickRay, // gamePlane, // intersection // ) // ) { // } //} } //simulation.tapShot(nearVector); //simulation.tapShot(finalVector); simulation.tapRay(pickRay); } else { // If we haven't been touched, let's look at the orientation. This in an attempt to lower // impulse from user's finger. float azimuth = input.getAzimuth(); float pitch = input.getPitch(); float roll = input.getRoll(); simulation.updateOrientation(azimuth, pitch, roll); } }