本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Contact.isTouching方法的典型用法代码示例。如果您正苦于以下问题:Java Contact.isTouching方法的具体用法?Java Contact.isTouching怎么用?Java Contact.isTouching使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.Contact
的用法示例。
在下文中一共展示了Contact.isTouching方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preSolve
import com.badlogic.gdx.physics.box2d.Contact; //导入方法依赖的package包/类
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
PlayerComponent player = getPlayer(contact);
if (!matches(contact, player.fixture)) { return; }
if (player.grounded && contact.isTouching()) {
contact.resetFriction();
}
}
示例2: checkContact
import com.badlogic.gdx.physics.box2d.Contact; //导入方法依赖的package包/类
private boolean checkContact(Contact contact) {
// ignore not touching contacts
if (!contact.isTouching()) return false;
Fixture fixtureA = contact.getFixtureA();
if (fixtureA == null) return false;
Fixture fixtureB = contact.getFixtureB();
if (fixtureB == null) return false;
Body bodyA = fixtureA.getBody();
Body bodyB = fixtureB.getBody();
String nameA = (String) bodyA.getUserData();
String nameB = (String) bodyB.getUserData();
if (nameA == null || nameB == null) { // nameless bodies, check if sound needs to be played
checkCollisionSound(contact, bodyA, bodyB);
return false;
} else if (nameA.equals(ObjectName.EDGE_SENSOR_NAME) || nameB.equals(ObjectName.EDGE_SENSOR_NAME)) { // check edges
Log.d(TAG, "onUpdate: OFF THE EDGE");
setBallOut();
return true;
} else if (nameA.equals(ObjectName.SINKHOLE_NAME) || nameB.equals(ObjectName.SINKHOLE_NAME)) { // check sinkhole
Log.d(TAG, "onUpdate: SINKHOLE");
setLevelComplete();
return true;
}
return false;
}