@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; }
@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 touchUp(int x, int y, int pointer, int button) { if (button == Buttons.LEFT) { secondData = null; dragTemp.set(Engine.screenToWorld(x, y)); //find the first data // box2dAABBTestPoint.set(dragTemp).scl(1f / Box2dObject.RADIO); PhysicalWorld.WORLD.QueryAABB(callbackSecond, box2dAABBTestPoint.x - 0.1f, box2dAABBTestPoint.y - 0.1f, box2dAABBTestPoint.x + 0.1f, box2dAABBTestPoint.y + 0.1f); } return false; }
public boolean touchDragged(int screenX, int screenY, int pointer) { secondData = null; dragTemp.set(Engine.screenToWorld(screenX, screenY)); //find the first data // box2dAABBTestPoint.set(dragTemp).scl(1f / Box2dObject.RADIO); PhysicalWorld.WORLD.QueryAABB(callbackSecond, box2dAABBTestPoint.x - 0.1f, box2dAABBTestPoint.y - 0.1f, box2dAABBTestPoint.x + 0.1f, box2dAABBTestPoint.y + 0.1f); return super.touchDragged(screenX, screenY, pointer); }
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { dragTemp.set(Engine.screenToWorld(screenX, screenY)); secondData = null; float dst = 0; if (data != null) { dst = data.position.dst(dragTemp); } if (dst > 100 && dst < 150) { rotateOn = true; } else { data = null; //find the first data // if (button == Buttons.LEFT) { box2dAABBTestPoint.set(dragTemp).scl(1f / Box2dObject.RADIO); PhysicalWorld.WORLD.QueryAABB(callback, box2dAABBTestPoint.x - 0.1f, box2dAABBTestPoint.y - 0.1f, box2dAABBTestPoint.x + 0.1f, box2dAABBTestPoint.y + 0.1f); } } return super.touchDown(screenX, screenY, pointer, button); }
public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (button == Buttons.LEFT) { jointsMenu.remove(); dragTemp.set(Engine.screenToWorld(screenX, screenY)); startPoint.set(dragTemp); data = null; secondData = null; //find the first data // if (button == Buttons.LEFT) { box2dAABBTestPoint.set(dragTemp).scl(1f / Box2dObject.RADIO); PhysicalWorld.WORLD.QueryAABB(callback, box2dAABBTestPoint.x - 0.1f, box2dAABBTestPoint.y - 0.1f, box2dAABBTestPoint.x + 0.1f, box2dAABBTestPoint.y + 0.1f); } } return super.touchDown(screenX, screenY, pointer, button); }
@Override public boolean touchDown(int x, int y, int x1, int y1) { super.touchDown(x,y,x1,y1); Log.debug("LiveMode.touchDown", "x="+x+ " y="+y); CollideCallback callback = new CollideCallback(); screen.getWorld().QueryAABB(callback, coordinates.x-.01f, coordinates.y-.01f, coordinates.x+.01f, coordinates.y+.01f); lastTouchPolygon = callback.getBody(); if(lastTouchPolygon != null){ lastTouchCoordinates = new Vector2(coordinates.x, coordinates.y); lastTouchPolygonLocalCoordinates = lastTouchPolygon.getLocalPoint(lastTouchCoordinates); Log.log("LiveMode.touchDown", "touched world coords: " + lastTouchCoordinates + " touched poly local coords: " + lastTouchPolygonLocalCoordinates); } return false; }
@Override public boolean touchDown (int x, int y, int pointer, int button) { // Mouse coordinates to world coordinates viewport.getCamera().unproject(point.set(x, y, 0)); if(button == Input.Buttons.RIGHT) { hitBody = null; // Check if a interactive body has been right-clicked world.QueryAABB(callback, point.x - 0.0001f, point.y - 0.0001f, point.x + 0.0001f, point.y + 0.0001f); if (hitBody == groundBody) hitBody = null; // if we hit an interactive body 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(point.x, point.y); def.maxForce = 1000.0f * hitBody.getMass(); mouseJoint = (MouseJoint)world.createJoint(def); hitBody.setAwake(true); } } return false; }
@Override public boolean touchDown (int x, int y, int pointer, int newParam) { if(world == null)return false; // translate the mouse coordinates to world coordinates testPoint.set(Engine.screenToWorld(x, y).scl(1/Box2dObject.RADIO)); // 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 = fixBody; 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 true; } return false; }
world.QueryAABB(areaCallback, aabb[0], aabb[1], aabb[4], aabb[5]);
world.QueryAABB(callback, point.x - 0.0001f, point.y - 0.0001f, point.x + 0.0001f, point.y + 0.0001f);
world.QueryAABB(areaCallback, aabb[0], aabb[1], aabb[4], aabb[5]);