com.badlogic.gdx.physics.box2d.QueryCallback Java Examples
The following examples show how to use
com.badlogic.gdx.physics.box2d.QueryCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DragAndDropSample.java From Codelabs with MIT License | 5 votes |
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { /* * Define a new QueryCallback. This callback will be used in * world.QueryAABB method. */ QueryCallback queryCallback = new QueryCallback() { @Override public boolean reportFixture(Fixture fixture) { boolean testResult; /* * If the hit point is inside the fixture of the body, create a * new MouseJoint. */ if (testResult = fixture.testPoint(touchPosition.x, touchPosition.y)) { mouseJointDef.bodyB = fixture.getBody(); mouseJointDef.target.set(touchPosition.x, touchPosition.y); mouseJoint = (MouseJoint) world.createJoint(mouseJointDef); } return testResult; } }; /* Translate camera point to world point */ camera.unproject(touchPosition.set(screenX, screenY, 0)); /* * Query the world for all fixtures that potentially overlap the touched * point. */ world.QueryAABB(queryCallback, touchPosition.x, touchPosition.y, touchPosition.x, touchPosition.y); return true; }
Example #2
Source File: PhysicsWorld.java From tilt-game-android with MIT License | 4 votes |
public void QueryAABB(final QueryCallback pCallback, final float pLowerX, final float pLowerY, final float pUpperX, final float pUpperY) { this.mWorld.QueryAABB(pCallback, pLowerX, pLowerY, pUpperX, pUpperY); }