@Override public boolean touchDragged (int x, int y, int pointer) { camera.unproject(curr.set(x, y, 0)); if (!(last.x == -1 && last.y == -1 && last.z == -1)) { camera.unproject(delta.set(last.x, last.y, 0)); delta.sub(curr); camera.position.add(delta.x, delta.y, 0); } last.set(x, y, 0); return false; }
public boolean touchDown (int x, int y, int pointer, int newParam) { if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { Vector3 touchPoint = new Vector3(x, y, 0); worldCamera.unproject(touchPoint); effect.setPosition(touchPoint.x, touchPoint.y); } return false; }
@Override public boolean touchDragged (int x, int y, int pointer) { // if a mouse joint exists we simply update // the target of the joint based on the new // mouse coordinates if (mouseJoint != null) { camera.unproject(testPoint.set(x, y, 0)); mouseJoint.setTarget(target.set(testPoint.x, testPoint.y)); } return false; }
@Override public boolean touchDragged (int x, int y, int pointer) { // if a mouse joint exists we simply update // the target of the joint based on the new // mouse coordinates if (mouseJoint != null) { camera.unproject(testPoint.set(x, y, 0)); mouseJoint.setTarget(target.set(testPoint.x, testPoint.y)); } return false; }
public boolean touchDown (int x, int y, int pointer, int newParam) { if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { Vector3 touchPoint = new Vector3(x, y, 0); worldCamera.unproject(touchPoint); effect.setPosition(touchPoint.x, touchPoint.y); } return false; }
public boolean touchDragged (int x, int y, int pointer) { if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { Vector3 touchPoint = new Vector3(x, y, 0); worldCamera.unproject(touchPoint); effect.setPosition(touchPoint.x, touchPoint.y); } return false; }
public boolean touchDragged (int x, int y, int pointer) { if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) { Vector3 touchPoint = new Vector3(x, y, 0); worldCamera.unproject(touchPoint); effect.setPosition(touchPoint.x, touchPoint.y); } return false; }
@Override public boolean touchDragged (int x, int y, int pointer) { if (!canDrag) return false; camera.unproject(curr.set(x, y, 0)); if (!(last.x == -1 && last.y == -1 && last.z == -1)) { camera.unproject(delta.set(last.x, last.y, 0)); delta.sub(curr); camera.position.add(delta.x, delta.y, 0); } last.set(x, y, 0); camera.update(); return false; }
@Override public boolean touchDragged (int x, int y, int pointer) { if (!canDrag) return false; camera.unproject(curr.set(x, y, 0)); if (!(last.x == -1 && last.y == -1 && last.z == -1)) { camera.unproject(delta.set(last.x, last.y, 0)); delta.sub(curr); camera.position.add(delta.x, delta.y, 0); } last.set(x, y, 0); camera.update(); return false; }
@Override public boolean touchDown (int x, int y, int pointerId, int button) { cam.unproject(point.set(x, y, 0)); if (button == Input.Buttons.LEFT) { if (last == null) { last = new Vector2(point.x, point.y); } else { createEdge(BodyType.StaticBody, last.x, last.y, point.x, point.y, 0); last.set(point.x, point.y); } } else { last = null; } return false; }
private void createScreenQuad () { if (screenQuad != null) return; screenQuad = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.ColorUnpacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords")); Vector3 vec0 = new Vector3(0, 0, 0); screenCamera.unproject(vec0); Vector3 vec1 = new Vector3(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0); screenCamera.unproject(vec1); screenQuad.setVertices(new float[] {vec0.x, vec0.y, 0, 1, 1, 1, 1, 0, 1, vec1.x, vec0.y, 0, 1, 1, 1, 1, 1, 1, vec1.x, vec1.y, 0, 1, 1, 1, 1, 1, 0, vec0.x, vec1.y, 0, 1, 1, 1, 1, 0, 0}); screenQuad.setIndices(new short[] {0, 1, 2, 2, 3, 0}); } }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); renderer.setProjectionMatrix(camera.combined); if (Gdx.input.isTouched()) camera.unproject(globalCoords.set(Gdx.input.getX(), Gdx.input.getY(), 0)); solveFakeIK(globalCoords); renderBones(); }
@Override public boolean touchDown (int x, int y, int pointer, int newParam) { // translate the mouse coordinates to world coordinates testPoint.set(x, y, 0); camera.unproject(testPoint); // ask the world which bodies are within the given // bounding box around the mouse pointer hitBody = null; world.QueryAABB(callback, testPoint.x - 0.1f, testPoint.y - 0.1f, testPoint.x + 0.1f, testPoint.y + 0.1f); // if we hit something we create a new mouse joint // and attach it to the hit body. if (hitBody != null) { MouseJointDef def = new MouseJointDef(); def.bodyA = groundBody; def.bodyB = hitBody; def.collideConnected = true; def.target.set(testPoint.x, testPoint.y); def.maxForce = 1000.0f * hitBody.getMass(); mouseJoint = (MouseJoint)world.createJoint(def); hitBody.setAwake(true); } else { for (Body box : boxes) world.destroyBody(box); boxes.clear(); createBoxes(); } return false; }
public void render () { // set the clear color and clear the screen. Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // draw the sprite batch.begin(); batch.draw(texture, spritePosition.x, spritePosition.y); batch.end(); // if a finger is down, set the sprite's x/y coordinate. if (Gdx.input.isTouched()) { // the unproject method takes a Vector3 in window coordinates (origin in // upper left corner, y-axis pointing down) and transforms it to world // coordinates. camera.unproject(spritePosition.set(Gdx.input.getX(), Gdx.input.getY(), 0)); } } }
@Override public boolean touchDown (int x, int y, int pointer, int button) { // translate the mouse coordinates to world coordinates camera.unproject(testPoint.set(x, y, 0)); // ask the world which bodies are within the given // bounding box around the mouse pointer hitBody = null; world.QueryAABB(callback, testPoint.x - 0.0001f, testPoint.y - 0.0001f, testPoint.x + 0.0001f, testPoint.y + 0.0001f); if (hitBody == groundBody) hitBody = null; // ignore kinematic bodies, they don't work with the mouse joint if (hitBody != null && hitBody.getType() == BodyType.KinematicBody) return false; // if we hit something we create a new mouse joint // and attach it to the hit body. if (hitBody != null) { MouseJointDef def = new MouseJointDef(); def.bodyA = groundBody; def.bodyB = hitBody; def.collideConnected = true; def.target.set(testPoint.x, testPoint.y); def.maxForce = 1000.0f * hitBody.getMass(); mouseJoint = (MouseJoint)world.createJoint(def); hitBody.setAwake(true); } return false; }
@Override public boolean touchDown (int screenX, int screenY, int pointer, int button) { PooledEffect effect = pool.obtain(); if (effect != null) { touchPos.set(screenX, screenY, 0.0f); camera.unproject(touchPos); activeEffects.add(effect); effect.setPosition(touchPos.x, touchPos.y); } return true; } }
@Override protected void process(int e) { final Pos pos = pm.get(e); aimAtTmp.set(Gdx.input.getX(), Gdx.input.getY(), 0); final Vector3 unproject = cameraSystem.camera.unproject(aimAtTmp); pos.xy.x = unproject.x; pos.xy.y = unproject.y; } }
public void update () { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (backBounds.contains(touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new MainMenuScreen(game)); return; } } }
public void update () { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (nextBounds.contains(touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new HelpScreen5(game)); } } }
public void update () { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (nextBounds.contains(touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); game.setScreen(new MainMenuScreen(game)); } } }