List of usage examples for com.badlogic.gdx.math Vector3 Vector3
public Vector3(final Vector2 vector, float z)
From source file:com.jameslennon.spacejump.util.ActionCam.java
License:Apache License
public void follow(Body b) { Vector3 pos = new Vector3(b.getPosition(), 0); Vector2 vel = b.getLinearVelocity(); // Globals.stage.getCamera().project(pos); position.x = pos.x - vel.x / Globals.PIXELS_PER_METER; // position.y = pos.y - vel.y; position.y = .5f * Globals.APP_HEIGHT / Globals.PIXELS_PER_METER; if (shaking)// ww w . jav a 2 s .com processShake(delta); // lerp.x = pos.x - vel.x; // lerp.y = pos.y - vel.y; // // if (isFixed) // throw new IllegalStateException("A fixed camera can not move"); // // if (shakeEnabled) { // if (shaking) { // processShake(delta); // } else { // super.position.lerp(lerp, smoothing); // // } // } }
From source file:com.sidereal.dolphinoes.behaviors.input.Clickable.java
License:Apache License
public void addTouchEvent(String inputProcessorName, int action, final TouchEvent touchEvent, InputEventType eventType, final boolean inside) { // make event that encapsulates the passed event TouchEvent clickableEvent = new TouchEvent() { @Override/* ww w. j av a 2 s . c om*/ public boolean run(TouchData inputData) { // translate touch input to a mouse position Vector3 translatedTouchPosition = new Vector3(inputData.getPosition(), 0); object.gameBatch.camera.unproject(translatedTouchPosition); if (area.contains(translatedTouchPosition.x, translatedTouchPosition.y) == inside) return touchEvent.run(inputData); else return false; } }; DolphinOES.input.addTouchEvent(inputProcessorName, action, clickableEvent, eventType); registeredTouchEvents.add(new TouchEventEntry(inputProcessorName, clickableEvent)); }
From source file:dk.sidereal.lumm.components.input.Clickable.java
License:Apache License
public void addTouchEvent(String inputProcessorName, int action, final OnTouchListener touchEvent, ActionType eventType, final boolean inside) { // make event that encapsulates the passed event OnTouchListener clickableEvent = new OnTouchListener() { @Override//from ww w . ja va2s . c om public boolean run(TouchData inputData) { // translate touch input to a mouse position Vector3 translatedTouchPosition = new Vector3(inputData.getPosition(), 0); object.getSceneLayer().camera.unproject(translatedTouchPosition); if (area.contains(translatedTouchPosition.x, translatedTouchPosition.y) == inside) return touchEvent.run(inputData); else return false; } }; Lumm.input.addOnTouchListener(inputProcessorName, action, clickableEvent, eventType); registeredTouchEvents.add(new TouchEventEntry(inputProcessorName, clickableEvent)); }
From source file:releasethekraken.screen.GameScreen.java
@Override public void render(float delta) //This gets called 60 times a second. Consider this the game loop. { super.render(delta); if (this.world.getPlayer() != null) { //Update player's aim position Vector3 mousePos3D = new Vector3(ReleaseTheKraken.inputHandler.getPointerLocations().first(), 0); //Convert mouse 0 to Vector 3 Vector3 worldMousePos3D = this.renderer.getCamera().unproject(mousePos3D); //Have the camera unproject the coordinates this.world.getPlayer().getAimPos().x = worldMousePos3D.x; this.world.getPlayer().getAimPos().y = worldMousePos3D.y; } // end if/* w w w . ja v a 2 s . co m*/ if (this.world.getPirateBase() == null) { //Take a screenshot of the game Pixmap pixmap = Screenshots.getScreenshot(true); this.rtk.pushScreen(new GameOverScreen(rtk, pixmap, true)); } // end if if (this.world.getPlayer() == null) { //Take a screenshot of the game Pixmap pixmap = Screenshots.getScreenshot(true); this.rtk.pushScreen(new GameOverScreen(rtk, pixmap, false)); } // end if this.world.update(); this.renderer.render(delta); }