本文整理匯總了Java中com.badlogic.gdx.physics.box2d.ContactListener類的典型用法代碼示例。如果您正苦於以下問題:Java ContactListener類的具體用法?Java ContactListener怎麽用?Java ContactListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ContactListener類屬於com.badlogic.gdx.physics.box2d包,在下文中一共展示了ContactListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addSystem
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例2: inserted
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
示例3: remove
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
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();
}
}
}
}
示例4: beginContact
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例5: endContact
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例6: preSolve
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例7: postSolve
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例8: addInternal
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
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);
}
示例9: get
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
private ContactListener get(short categoryA, short categoryB) {
ObjectMap<Short, ContactListener> listenersMap = listeners.get(categoryA);
if (listenersMap == null) {
return null;
}
return listenersMap.get(categoryB);
}
示例10: beginContact
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例11: endContact
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例12: preSolve
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例13: postSolve
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
@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);
}
}
示例14: addListenerInternal
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
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);
}
示例15: getListener
import com.badlogic.gdx.physics.box2d.ContactListener; //導入依賴的package包/類
private ContactListener getListener(short categoryA, short categoryB) {
ObjectMap<Short, ContactListener> listenerCollection = listeners.get(categoryA);
if (listenerCollection == null) {
return null;
}
return listenerCollection.get(categoryB);
}