public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) { Body body = fixture.getBody(); Object userData = body.getUserData(); if (userData != null) { int index = (Integer) userData; if (index == 0) { // filter return -1f; } } m_hit = true; m_point = point; m_normal = normal; return 0f; }
public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) { Body body = fixture.getBody(); Object userData = body.getUserData(); if (userData != null) { int index = (Integer) userData; if (index == 0) { // filter return -1f; } } m_hit = true; m_point = point; m_normal = normal; return fraction; }
public void beginContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_sensor) { Object userData = fixtureB.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = true; } } if (fixtureB == m_sensor) { Object userData = fixtureA.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = true; } } }
public void endContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_sensor) { Object userData = fixtureB.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = false; } } if (fixtureB == m_sensor) { Object userData = fixtureA.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = false; } } }
public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) { Body body = fixture.getBody(); int index = 0; Object userData = body.getUserData(); if (userData != null) { index = (Integer) userData; if (index == 0) { // filter return -1f; } } assert (m_count < e_maxCount); m_points[m_count].set(point); m_normals[m_count].set(normal); ++m_count; if (m_count == e_maxCount) { return 0f; } return 1f; }
private void setForDestruction(Body myBody) throws JSONException { if(myBody.getUserData()!=null) { ((JSONObject)myBody.getUserData()).put("deleteStatus", true); } }
Iterator<Body> i = world.getBodies(); Body node; while (i.hasNext()) { node=i.next(); if(node.getUserData() == Constants.BodyType.DESTROY){ removeBodySafely(node); } }
world.step(timestep, 3, 3); for(Body b : world.getBodies()) if("DESTROY".equals(b.getUserData()) world.destroyBody(body);
void beginContact (Contact cp) { // Get both fixtures Fixture f1 = cp.getFixtureA(); Fixture f2 = cp.getFixtureB(); // Get both bodies Body b1 = f1.getBody(); Body b2 = f2.getBody(); // Get our objects that reference these bodies Object o1 = b1.getUserData(); Object o2 = b2.getUserData(); //Detect player-enemy collision if (b1.getUserData() == "player" && b2.getUserData() == "enemy") { //... Do stuff here } if (b2.getUserData() == "player" && b1.getUserData() == "enemy") { //... Do stuff here }
public void beginContact(final Contact pContact) { final Body BodyA = pContact.getFixtureA().getBody(); final Body BodyB = pContact.getFixtureB().getBody(); if(BodyA.getUserData() == "Ball" && BodyB.getUserData() == "Hole"){ SwapHoleAndBall(); ......
public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) { Body body = fixture.getBody(); Object userData = body.getUserData(); if (userData != null) { int index = (Integer) userData; if (index == 0) { // filter return -1f; } } m_hit = true; m_point = point; m_normal = normal; return fraction; }
public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) { Body body = fixture.getBody(); Object userData = body.getUserData(); if (userData != null) { int index = (Integer) userData; if (index == 0) { // filter return -1f; } } m_hit = true; m_point = point; m_normal = normal; return 0f; }
@Override public void beginContact(Contact aContact) { Body theObjectA = aContact.getFixtureA().getBody(); Body theObjectB = aContact.getFixtureB().getBody(); queuedEventsOfLastLoop.add(new GameObjectCollision((GameObjectInstance) theObjectA.getUserData(), (GameObjectInstance) theObjectB.getUserData())); }
public void beginContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_sensor) { Object userData = fixtureB.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = true; } } if (fixtureB == m_sensor) { Object userData = fixtureA.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = true; } } }
for (Body b = world.getBodyList(); b != null; b = b.getNext()) { CCSprite sprite = (CCSprite)b.getUserData(); if(sprite != null) { sprite.setPosition(worldToScreen(b.getPosition()))); sprite.setRotation(-1.0f * (float)Math.toDegrees((b.getAngle()))); } }
public void endContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_sensor) { Object userData = fixtureB.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = false; } } if (fixtureB == m_sensor) { Object userData = fixtureA.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = false; } } }
CopyOnWriteArrayList<Entity> entities = new CopyOnWriteArrayList<Entity>(); public void deleteEntities() { for(Entity entity: entities){ Body body = entity.getBody(); if (body != null) { EntityData data = (EntityData) body.getUserData(); if (data.isFlaggedForDelete()) { final Array<JointEdge> list = body.getJointList(); //delete all joints attached while (list.size > 0) { myWorld.getWorld().destroyJoint(list.get(0).joint); } //nullify everything, remove the entity from entities and destroy the body body.setUserData(null); myWorld.getWorld().destroyBody(body); entities.remove(entity); body = null; } } } }
public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) { Body body = fixture.getBody(); int index = 0; Object userData = body.getUserData(); if (userData != null) { index = (Integer) userData; if (index == 0) { // filter return -1f; } } assert (m_count < e_maxCount); m_points[m_count].set(point); m_normals[m_count].set(normal); ++m_count; if (m_count == e_maxCount) { return 0f; } return 1f; }
for (Body body : bodies) { Sprite playerSprite = (Sprite) body.getUserData(); playerSprite.setPosition(body.getPosition().x, body.getPosition().y); playerSprite.draw(spriteBatch); }
mScene.registerUpdateHandler(new Timer(1f, new ITimerCallback() { @Override public void onTick() { Iterator<Body> it = bxWorld.getBodies();` while(it.hasNext()) { Body b = it.next(); Object userData = b.getUserData(); if (userData != null && userData instanceof Sprite) { //Synchronize the Sprites position and rotation with the corresponding body final Sprite sprite = (Sprite)userData; final Vector2 pos = b.getPosition(); sprite.setPosition(pos.x * PTM_RATIO, pos.y * PTM_RATIO); sprite.setRotation(-1.0f * ccMacros.CC_RADIANS_TO_DEGREES(b.getAngle())); } } } }));