Java 类com.badlogic.gdx.physics.box2d.ContactListener 实例源码

项目:GDX-Logic-Bricks    文件:LogicBricksEngine.java   
@Override
public void addSystem(EntitySystem system) {
    super.addSystem(system);
    if (EntityListener.class.isInstance(system)) {
        this.addEntityListener((EntityListener) system);

    }
    if (InputProcessor.class.isInstance(system)) {
        inputs.addProcessor((InputProcessor) system);

    }
    if (ContactListener.class.isInstance(system)) {
        contactSystems.add((ContactListener) system);

    }

}
项目:Merkurius-LD27    文件:ScaledBox2DSystem.java   
@Override
protected void inserted(Entity e) {
    World b2World;

    // Adding to box2D world
    if( universe.containsKey(transformMapper.get(e).mapId) ) {
        b2World = universe.get(transformMapper.get(e).mapId);
    } else {
        b2World = newWorld(e);
        b2World.setContactListener(this);
        universe.put( transformMapper.get(e).mapId, b2World );
    }

    // Adding contact listeners
    if( !contactListeners.containsKey(transformMapper.get(e).mapId) ) {
        contactListeners.put( transformMapper.get(e).mapId, new ArrayList<ContactListener>() );
    }

    // Body initialization
    bodyMapper.get(e).physicsBody.initialize( b2World );
    bodyMapper.get(e).getBody().setUserData(e);
    previousMap.put(e, transformMapper.get(e).mapId);
    updateBody(e);
}
项目:libgdxjam    文件:CollisionHandler.java   
public void remove(ContactListener listener) {
    for (ObjectMap<Short, ContactListener> listenerMap : listeners.values()) {
        ObjectMap.Entries<Short, ContactListener> entries = listenerMap.entries();

        while (entries.hasNext()) {
            ObjectMap.Entry<Short, ContactListener> entry = entries.next();

            if (entry.value == listener) {
                entries.remove();
            }
        }
    }
}
项目:libgdxjam    文件:CollisionHandler.java   
@Override
public void beginContact(Contact contact) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = get(
        fixtureA.getFilterData().categoryBits,
        fixtureB.getFilterData().categoryBits
    );

    if (listener != null) {
        listener.beginContact(contact);
    }
}
项目:libgdxjam    文件:CollisionHandler.java   
@Override
public void endContact(Contact contact) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = get(
        fixtureA.getFilterData().categoryBits,
        fixtureB.getFilterData().categoryBits
    );

    if (listener != null) {
        listener.endContact(contact);
    }
}
项目:libgdxjam    文件:CollisionHandler.java   
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = get(
        fixtureA.getFilterData().categoryBits,
        fixtureB.getFilterData().categoryBits
    );

    if (listener != null) {
        listener.preSolve(contact, oldManifold);
    }
}
项目:libgdxjam    文件:CollisionHandler.java   
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = get(
        fixtureA.getFilterData().categoryBits,
        fixtureB.getFilterData().categoryBits
    );

    if (listener != null) {
        listener.postSolve(contact, impulse);
    }
}
项目:libgdxjam    文件:CollisionHandler.java   
private void addInternal(short categoryA, short categoryB, ContactListener listener) {
    ObjectMap<Short, ContactListener> listenerMap = listeners.get(categoryA);

    if (listenerMap == null) {
        listenerMap = new ObjectMap<Short, ContactListener>();
        listeners.put(categoryA, listenerMap);
    }

    listenerMap.put(categoryB, listener);
}
项目:libgdxjam    文件:CollisionHandler.java   
private ContactListener get(short categoryA, short categoryB) {
    ObjectMap<Short, ContactListener> listenersMap = listeners.get(categoryA);

    if (listenersMap == null) {
        return null;
    }

    return listenersMap.get(categoryB);
}
项目:sioncore    文件:CollisionHandler.java   
@Override
public void beginContact(Contact contact) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = getListener(fixtureA.getFilterData().categoryBits,
                                           fixtureB.getFilterData().categoryBits);

    if (listener != null) {
        listener.beginContact(contact);
    }
}
项目:sioncore    文件:CollisionHandler.java   
@Override
public void endContact(Contact contact) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = getListener(fixtureA.getFilterData().categoryBits,
                                           fixtureB.getFilterData().categoryBits);

    if (listener != null) {
        listener.endContact(contact);
    }
}
项目:sioncore    文件:CollisionHandler.java   
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = getListener(fixtureA.getFilterData().categoryBits,
                                           fixtureB.getFilterData().categoryBits);

    if (listener != null) {
        listener.preSolve(contact, oldManifold);
    }
}
项目:sioncore    文件:CollisionHandler.java   
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    Fixture fixtureA = contact.getFixtureA();
    Fixture fixtureB = contact.getFixtureB();

    ContactListener listener = getListener(fixtureA.getFilterData().categoryBits,
                                           fixtureB.getFilterData().categoryBits);

    if (listener != null) {
        listener.postSolve(contact, impulse);
    }
}
项目:sioncore    文件:CollisionHandler.java   
private void addListenerInternal(short categoryA, short categoryB, ContactListener listener) {
    ObjectMap<Short, ContactListener> listenerCollection = listeners.get(categoryA);

    if (listenerCollection == null) {
        listenerCollection = new ObjectMap<Short, ContactListener>();
        listeners.put(categoryA, listenerCollection);
    }

    listenerCollection.put(categoryB, listener);
}
项目:sioncore    文件:CollisionHandler.java   
private ContactListener getListener(short categoryA, short categoryB) {
    ObjectMap<Short, ContactListener> listenerCollection = listeners.get(categoryA);

    if (listenerCollection == null) {
        return null;
    }

    return listenerCollection.get(categoryB);
}
项目:Blob-Game    文件:ContactHandler.java   
@Override
public void beginContact(Contact contact) {
    mContacts.add(new StableContact(contact));
    Actor aa = (Actor) contact.getFixtureA().getBody().getUserData();
    Actor ab = (Actor) contact.getFixtureB().getBody().getUserData();
    if (aa instanceof Knocked) {
        ((Knocked) aa).knocked(ab);
    } else if (ab instanceof Knocked) {
        ((Knocked) ab).knocked(aa);
    }
    for (ContactListener l : mListeners) {
        l.beginContact(contact);
    }
}
项目:Blob-Game    文件:ContactHandler.java   
@Override
public void endContact(Contact contact) {
    for (int i = 0; i < mContacts.size(); i++) {
        StableContact c = mContacts.get(i);
        if (c.getFixtureA() == contact.getFixtureA()
                && c.getFixtureB() == contact.getFixtureB()) {
            mContacts.remove(i);
        }
    }

    for (ContactListener l : mListeners) {
        l.endContact(contact);
    }
}
项目:Merkurius-LD27    文件:ScaledBox2DSystem.java   
@SuppressWarnings("unchecked")
public ScaledBox2DSystem() {
    super( Aspect.getAspectForAll(Transform.class, PhysicsBodyComponent.class) );
    universe        = new Hashtable<Integer,World>();
    contactListeners= new Hashtable<Integer, List<ContactListener>>();
    globalListeners = new ArrayList<ContactListener>();
    previousMap     = new Hashtable<Entity, Integer>();
}
项目:libgdxjam    文件:CollisionHandler.java   
public void add(short categoryA, short categoryB, ContactListener listener) {
    addInternal(categoryA, categoryB, listener);
    addInternal(categoryB, categoryA, listener);
}
项目:libgdxGP    文件:ContactMultiListener.java   
public void addContactListener(ContactListener contactListener) {
    contactListeners.add(contactListener);
}
项目:libgdxGP    文件:ContactMultiListener.java   
public void removeContactListener(ContactListener contactListener) {
    contactListeners.remove(contactListener);
}
项目:libgdxGP    文件:ContactMultiListener.java   
@Override
public void beginContact(Contact contact) {
    for (ContactListener contactListener : contactListeners) {
        contactListener.beginContact(contact);
    }
}
项目:libgdxGP    文件:ContactMultiListener.java   
@Override
public void endContact(Contact contact) {
    for (ContactListener contactListener : contactListeners) {
        contactListener.endContact(contact);
    }
}
项目:libgdxGP    文件:ContactMultiListener.java   
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
    for (ContactListener contactListener : contactListeners) {
        contactListener.preSolve(contact, oldManifold);
    }
}
项目:libgdxGP    文件:ContactMultiListener.java   
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    for (ContactListener contactListener : contactListeners) {
        contactListener.postSolve(contact, impulse);
    }
}
项目:tilt-game-android    文件:PhysicsWorld.java   
public void setContactListener(final ContactListener pListener) {
    this.mWorld.setContactListener(pListener);
}
项目:BactMan-Adventures    文件:BaseGame.java   
public ContactListener getContactListener() {
    return null;
}
项目:sioncore    文件:CollisionHandler.java   
public CollisionHandler() {
    listeners = new ObjectMap<Short, ObjectMap<Short, ContactListener>>();
}
项目:sioncore    文件:CollisionHandler.java   
public void addListener(short categoryA, short categoryB, ContactListener listener) {
    addListenerInternal(categoryA, categoryB, listener);
    addListenerInternal(categoryB, categoryA, listener);
}
项目:ninja-rabbit    文件:ContactListenerMultiplexer.java   
public ContactListenerMultiplexer(final ContactListener... receivers) {
    super(receivers);
}
项目:ninja-rabbit    文件:ContactListenerMultiplexer.java   
public ContactListenerMultiplexer(final Array<ContactListener> receivers) {
    super(receivers);
}
项目:ninja-rabbit    文件:ContactListenerMultiplexer.java   
@Override
public void beginContact(final Contact contact) {
    for (ContactListener listener : receivers) {
        listener.beginContact(contact);
    }
}
项目:ninja-rabbit    文件:ContactListenerMultiplexer.java   
@Override
public void preSolve(final Contact contact, final Manifold oldManifold) {
    for (ContactListener listener : receivers) {
        listener.preSolve(contact, oldManifold);
    }
}
项目:ninja-rabbit    文件:ContactListenerMultiplexer.java   
@Override
public void postSolve(final Contact contact, final ContactImpulse impulse) {
    for (ContactListener listener : receivers) {
        listener.postSolve(contact, impulse);
    }
}
项目:ninja-rabbit    文件:ContactListenerMultiplexer.java   
@Override
public void endContact(final Contact contact) {
    for (ContactListener listener : receivers) {
        listener.endContact(contact);
    }
}
项目:GDX-Logic-Bricks    文件:LogicBricksEngine.java   
public Array<ContactListener> getContactSystems() {
    return contactSystems;
}
项目:Blob-Game    文件:ContactHandler.java   
/**
 * Constructor
 */
public ContactHandler() {
    mContacts = new ArrayList<StableContact>();
    mListeners = new ArrayList<ContactListener>();
}
项目:Blob-Game    文件:ContactHandler.java   
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
    for (ContactListener l : mListeners) {
        l.preSolve(contact, oldManifold);
    }
}
项目:Blob-Game    文件:ContactHandler.java   
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
    for (ContactListener l : mListeners) {
        l.postSolve(contact, impulse);
    }
}
项目:Blob-Game    文件:ContactHandler.java   
public void addListener(ContactListener listen) {
    mListeners.add(listen);
}