当前位置: 首页>>代码示例>>Java>>正文


Java Contact类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:19,代码来源:Field.java

示例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);

}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:19,代码来源:WorldContactListener.java

示例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);

}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:19,代码来源:WorldContactListener.java

示例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;
        }
    }

}
 
开发者ID:MissionBit,项目名称:summer17-android,代码行数:18,代码来源:WorldContactListener.java

示例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--;
	}
}
 
开发者ID:heyzqt,项目名称:libGdx-xiyou,代码行数:20,代码来源:Box2DContactListener.java

示例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());;
            }
        }
    }
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:17,代码来源:CollisionHandler.java

示例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());;
            }
        }
    }
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:17,代码来源:CollisionHandler.java

示例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);
        }
    }
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:21,代码来源:Player.java

示例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);
        }
    }
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:19,代码来源:CollisionListener.java

示例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
	);
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:21,代码来源:PlayerBulletContactListener.java

示例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;
	}
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:19,代码来源:SensorSystem.java

示例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;
	}
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:19,代码来源:SensorSystem.java

示例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;
	}
}
 
开发者ID:zozotintin,项目名称:Dodgy-Dot,代码行数:27,代码来源:GameScreen.java

示例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;
    }
}
 
开发者ID:danirod,项目名称:jumpdontdie,代码行数:17,代码来源:Box2DScreen.java

示例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();
	}
}
 
开发者ID:GuilledelaCruz,项目名称:METEORIC,代码行数:18,代码来源:ContactEntities.java


注:本文中的com.badlogic.gdx.physics.box2d.Contact类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。