本文整理汇总了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);
}