本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Contact类的典型用法代码示例。如果您正苦于以下问题:Java Contact类的具体用法?Java Contact怎么用?Java Contact使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Contact类属于com.badlogic.gdx.physics.box2d包,在下文中一共展示了Contact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override public void endContact(Contact contact) {
Fixture fixture = null;
Ball ball = ballWithBody(contact.getFixtureA().getBody());
if (ball != null) {
fixture = contact.getFixtureB();
}
else {
ball = ballWithBody(contact.getFixtureB().getBody());
if (ball != null) {
fixture = contact.getFixtureA();
}
}
if (ball != null) {
contactedBalls.add(ball);
contactedFixtures.add(fixture);
}
}
示例2: beginContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void beginContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
ContactHandler handler;
handler = beginContactFunctions.get(fixA.getFilterData().categoryBits);
if (handler != null)
handler.handle(fixA, fixB);
handler = beginContactFunctions.get(fixB.getFilterData().categoryBits);
if (handler != null)
handler.handle(fixB, fixA);
}
示例3: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void endContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
ContactHandler handler;
handler = endContactFunctions.get(fixA.getFilterData().categoryBits);
if (handler != null)
handler.handle(fixA, fixB);
handler = endContactFunctions.get(fixB.getFilterData().categoryBits);
if (handler != null)
handler.handle(fixB, fixA);
}
示例4: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void endContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
if (fixA.getUserData() == "bottom" || fixB.getUserData() == "bottom") {
Fixture bottom = fixA.getUserData() == "bottom" ? fixA : fixB;
Fixture object = bottom == fixA ? fixB : fixA;
//resets object touched
if (object.getUserData() != null &&
InteractiveTileObject.class.isAssignableFrom(object.getUserData().getClass())) {
isObjectTouched = NoObjectionGame.DEFAULT;
}
}
}
示例5: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void endContact(Contact contact) {
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
// 夹具为空时,碰撞直接返回不执行。
if (fixtureA == null || fixtureB == null) {
return;
}
//孙悟空跳跃结束
if (fixtureA.getUserData() != null && fixtureA.getUserData().equals("foot")) {
// 计数器减1
platformNum--;
}
if (fixtureB.getUserData() != null && fixtureB.getUserData().equals("foot")) {
// 计数器减1
platformNum--;
}
}
示例6: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void endContact(Contact contact) {
Pair<Collider> pair = checkObjects(contact);
if (pair != null) {
if(pair.getA() instanceof WorldObject && pair.getB() instanceof WorldObject) {
pair.getA().endCollision(pair.getB());
pair.getB().endCollision(pair.getA());
} else {
if(pair.getA() instanceof Entrypoint) {
pair.getA().endCollision(pair.getB());
} else if(pair.getB() instanceof Entrypoint) {
pair.getB().endCollision(pair.getA());;
}
}
}
}
示例7: beginContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void beginContact(Contact contact) {
Pair<Collider> pair = checkObjects(contact);
if (pair != null) {
if(pair.getA() instanceof WorldObject && pair.getB() instanceof WorldObject) {
pair.getA().startCollision(pair.getB());
pair.getB().startCollision(pair.getA());
} else {
if(pair.getA() instanceof Entrypoint) {
pair.getA().startCollision(pair.getB());
} else if(pair.getB() instanceof Entrypoint) {
pair.getB().startCollision(pair.getA());;
}
}
}
}
示例8: handleFootContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
private void handleFootContact(Contact contact, boolean onBeginContact) {
Fixture footSensor = getFootSensor();
if (contact.getFixtureA() == footSensor || contact.getFixtureB() == footSensor) {
Fixture otherFixture =
(footSensor == contact.getFixtureA()) ? contact.getFixtureB() : contact.getFixtureA();
if (!otherFixture.isSensor()) {
if (onBeginContact) {
if (numFootContacts == 0) {
land();
}
numFootContacts++;
} else {
numFootContacts--;
}
numFootContacts = Math.max(0, numFootContacts);
}
}
}
示例9: setEntityContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
private void setEntityContact(Contact contact, Entity entityA, Entity entityB,
boolean beginContact) {
if (entityA != null) {
if (beginContact) {
entityA.onBeginContact(contact, entityB);
} else {
entityA.onEndContact(contact, entityB);
}
}
if (entityB != null) {
if (beginContact) {
entityB.onBeginContact(contact, entityA);
} else {
entityB.onEndContact(contact, entityA);
}
}
}
示例10: beginContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void beginContact(Contact contact) {
Entity entity = getEntity(contact, PlayerComponent.class);
spawnSmoke(entity);
laserHit.play();
engine.removeEntity(entity);
Timer.instance().scheduleTask(
new Task() {
@Override
public void run() {
EventManager.fireEvent(
SceneManager.getCurrentScene(),
new Event(EventType.YOU_HAVE_BEEN_KILLED, false, false)
);
}
},
2.0f
);
}
示例11: beginContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void beginContact(Contact contact) // TODO: NOT SURE BUT... I THINK SAME ENTITY IS PROCESSED AT LEAST TWICE
{
for (Entity entity : getEntities())
{
SensorComponent sensor = Mappers.sensor.get(entity);
if (!matches(contact, sensor.sensorFixture)) { continue; }
if(sensor.isBoxSensible &&
!sensor.isCollidingPlayer &&
sensor.sensorReactionEnter != null)
{
sensor.sensorReactionEnter.run();
}
sensor.isCollidingBox = true;
}
}
示例12: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void endContact(Contact contact)
{
for (Entity entity : getEntities())
{
SensorComponent sensor = Mappers.sensor.get(entity);
if (!matches(contact, sensor.sensorFixture)) { continue; }
if(sensor.isBoxSensible &&
!sensor.isCollidingPlayer &&
sensor.sensorReactionEnter != null)
{
sensor.sensorReactionExit.run();
}
sensor.isCollidingBox = false;
}
}
示例13: beginContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void beginContact(Contact contact) {
// TODO Auto-generated method stub
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
//logger.info("contact");
if (state == GAME_RUNNING) {
if (fixtureA.getFilterData().categoryBits == CATEGORY_PLAYER &&
fixtureB.getFilterData().categoryBits == CATEGORY_ENEMY) {
//fixtureA.getFilterData().maskBits = 0;
state = GAME_OVER_SETUP;
}
else if (fixtureA.getFilterData().categoryBits == CATEGORY_ENEMY &&
fixtureB.getFilterData().categoryBits == CATEGORY_PLAYER) {
//fixtureB.getFilterData().maskBits = 0;
state = GAME_OVER_SETUP;
}
}
if ((fixtureA.isSensor() == true && fixtureB.getFilterData().categoryBits == CATEGORY_PLAYER)
|| (fixtureB.isSensor() == true && fixtureA.getFilterData().categoryBits == CATEGORY_PLAYER)) {
state = BALL_DESTROYED;
}
}
示例14: endContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
@Override
public void endContact(Contact contact) {
// End the collision.
Fixture fixtureA = contact.getFixtureA(), fixtureB = contact.getFixtureB();
// This is another way for guessing which fixture are you working with. If you have
// the reference to that fixture you can just check if both variable reference the
// same instance.
if (fixtureA == minijoeFixture && fixtureB == floorFixture) {
isJumping = true;
}
if (fixtureA == floorFixture && fixtureB == minijoeFixture) {
isJumping = true;
}
}
示例15: beginContact
import com.badlogic.gdx.physics.box2d.Contact; //导入依赖的package包/类
public void beginContact(Contact contact) {
if(contact.getFixtureA().getBody().getPosition().x * GameMain.PIXELS_TO_METERS < GameMain.WIDTH / 2){
screen.forceToZero(-1);
}else{
screen.forceToZero(1);
}
Short a = contact.getFixtureA().getFilterData().categoryBits;
Short b = contact.getFixtureB().getFilterData().categoryBits;
if (a.equals(GameMain.METEOR_ENTITY) && b.equals(GameMain.OBSTACLE_ENTITY) ||
b.equals(GameMain.METEOR_ENTITY) && a.equals(GameMain.OBSTACLE_ENTITY)){
screen.endGame();
sound.play();
}
}