@Override public void endContact (Contact contact) { System.out.println(String.format(" endContact() addr=%d", getContactAddr(contact))); System.out.println(String.format(" endContact() addrA=%d, addrB=%d", getFixtureAddrA(contact), getFixtureAddrB(contact))); System.out.println(String.format(" endContact() fixA=%s, fixB=%s", contact.getFixtureA(), contact.getFixtureB())); final Fixture fixtureA = contact.getFixtureA(); final Fixture fixtureB = contact.getFixtureB(); if(fixtureA == null || fixtureB == null) { throw new RuntimeException("No fixture found."); } }
public void preSolve (Contact contact, Manifold oldManifold) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_platform || fixtureB == m_platform) { contact.setTangentSpeed(5.0f); } }
@Override public void beginContact (Contact contact) { System.out.println(String.format("beginContact() addr=%d", getContactAddr(contact))); System.out.println(String.format("beginContact() addrA=%d, addrB=%d", getFixtureAddrA(contact), getFixtureAddrB(contact))); System.out.println(String.format("beginContact() fixA=%s, fixB=%s", contact.getFixtureA(), contact.getFixtureB())); final Body toRemove = contact.getFixtureA().getBody().getType() == BodyType.DynamicBody ? contact.getFixtureA().getBody() : contact.getFixtureB().getBody(); Gdx.app.postRunnable(new Runnable() { @Override public void run () { world.destroyBody(toRemove); } }); }
private boolean isPlayerGrounded (float deltaTime) { groundedPlatform = null; Array<Contact> contactList = world.getContactList(); for (int i = 0; i < contactList.size; i++) { Contact contact = contactList.get(i); if (contact.isTouching() && (contact.getFixtureA() == playerSensorFixture || contact.getFixtureB() == playerSensorFixture)) { Vector2 pos = player.getPosition(); WorldManifold manifold = contact.getWorldManifold(); boolean below = true; for (int j = 0; j < manifold.getNumberOfContactPoints(); j++) { below &= (manifold.getPoints()[j].y < pos.y - 1.5f); } if (below) { if (contact.getFixtureA().getUserData() != null && contact.getFixtureA().getUserData().equals("p")) { groundedPlatform = (Platform)contact.getFixtureA().getBody().getUserData(); } if (contact.getFixtureB().getUserData() != null && contact.getFixtureB().getUserData().equals("p")) { groundedPlatform = (Platform)contact.getFixtureB().getBody().getUserData(); } return true; } return false; } } return false; }
private void drawContact (Contact contact) { WorldManifold worldManifold = contact.getWorldManifold(); if (worldManifold.getNumberOfContactPoints() == 0) return; Vector2 point = worldManifold.getPoints()[0]; renderer.setColor(getColorByBody(contact.getFixtureA().getBody())); renderer.point(point.x, point.y, 0); }
public void beginContact(Contact c) { Body b = c.getFixtureA().getBody(); Image i = (Image) blocks.get(b); if (i != null) { i.remove(); } else if (b == floorBody) { show(); } } public void endContact(Contact c) {}
@Override public void endContact(Contact contact) { Fixture fixture = null; Ball ball = ballWithBody(contact.getFixtureA().getBody()); if (ball != null) { fixture = contact.getFixtureB(); } else { ball = ballWithBody(contact.getFixtureB().getBody()); if (ball != null) { fixture = contact.getFixtureA(); } } if (ball != null) { contactedBalls.add(ball); contactedFixtures.add(fixture); } }
@Override public void process (Contact contact, ContactImpulse impulse) { Fixture a = contact.getFixtureA(); Fixture b = contact.getFixtureB(); ifCarThenCollide(contact, a, b, impulse); ifCarThenCollide(contact, b, a, impulse); }
@Override public void beginContact(Contact contact) { // TODO Auto-generated method stub Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); Body bodyA = fixtureA.getBody(); Body bodyB = fixtureB.getBody(); if(bodyA == pointerBody && bodyB != groundBody) bodyB.setUserData(true); else if(bodyB == pointerBody && bodyA != groundBody) bodyA.setUserData(true); }
@Override public void endContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); Body bodyA = fixtureA.getBody(); if(c.getFixtureA() == contact.getFixtureA() || c.getFixtureB() == contact.getFixtureA()) { break; else if(c.getFixtureA().getFilterData().maskBits == MASK_PLAYER && c.getFixtureA() != fixtureB) { e.setAngry(true); break; if(c.getFixtureA() == contact.getFixtureB() || c.getFixtureB() == contact.getFixtureB()) { break; else if(c.getFixtureA().getFilterData().maskBits == MASK_PLAYER && c.getFixtureA() != fixtureA) { e.setAngry(true); break;
private void drawContact (Contact contact) { WorldManifold worldManifold = contact.getWorldManifold(); if (worldManifold.getNumberOfContactPoints() == 0) return; Vector2 point = worldManifold.getPoints()[0]; renderer.setColor(getColorByBody(contact.getFixtureA().getBody())); renderer.point(point.x, point.y, 0); }
@Override public void beginContact(Contact contact) { // TODO Auto-generated method stub Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); Body bodyA = fixtureA.getBody(); Body bodyB = fixtureB.getBody(); if (fixtureA.isSensor()) { Enemy e = (Enemy) bodyA.getUserData(); e.setAngry(true); //Gdx.app.log(TAG, "T-Rex is angry!!!"); } else if(fixtureB.isSensor()) { Enemy e = (Enemy) bodyB.getUserData(); e.setAngry(true); //Gdx.app.log(TAG, "T-Rex is angry!!!"); } }
@Override public void beginContact(Contact contact) { Body a = contact.getFixtureA().getBody(); Body b = contact.getFixtureB().getBody(); if ((BodyUtils.bodyIsRunner(a) && BodyUtils.bodyIsEnemy(b)) || (BodyUtils.bodyIsEnemy(a) && BodyUtils.bodyIsRunner(b))) { runner.hit(); } else if ((BodyUtils.bodyIsRunner(a) && BodyUtils.bodyIsGround(b)) || (BodyUtils.bodyIsGround(a) && BodyUtils.bodyIsRunner(b))) { runner.landed(); } }
if (contact.getFixtureA().getUserData() == CarType.PlayerCar) { fcar = contact.getFixtureA(); } else if (contact.getFixtureB().getUserData() == CarType.PlayerCar) { fcar = contact.getFixtureB();
@Override public void beginContact(Contact contact) { Fixture fixA = contact.getFixtureA(); Fixture fixB = contact.getFixtureB();
@Override public void beginContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB();