本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Fixture.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Java Fixture.getUserData方法的具体用法?Java Fixture.getUserData怎么用?Java Fixture.getUserData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.Fixture
的用法示例。
在下文中一共展示了Fixture.getUserData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: endContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的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;
}
}
}
示例2: endContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的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--;
}
}
示例3: processCollision
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public void processCollision(Fixture colliderA, Fixture colliderB, boolean collisionSignal) {
if (colliderA.isSensor() && !colliderB.isSensor()) {
Integer indexEntityA = (Integer) colliderA.getBody().getUserData();
Integer indexEntityB = (Integer) colliderB.getBody().getUserData();
String tagSensorA = (String) colliderA.getUserData();
if (indexEntityA != null && indexEntityB != null && tagSensorA != null && tagSensorA.equals("RadarSensor")) {
GameEntity entityB = Indexed.getInteractiveEntity(indexEntityB);
if (entityB != null) {
for (SensorEntity entity : sensorGroup.getEntities()) {
RadarSensor radar = entity.getRadarSensor();
if (entityB.getTags().values.contains(radar.targetTag)) {
if (collisionSignal) {
Indexed.addEntityInSensor(entity, entityB);
} else {
Indexed.removeEntityInSensor(entity, entityB);
}
radar.collisionSignal = collisionSignal;
}
}
}
}
}
}
示例4: checkFootCollision
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
/**
* @param fixtureA
* @param bodyB
*/
public static void checkFootCollision(final Fixture fixtureA, final Body bodyB) {
if ((fixtureA.getUserData() == null) || (fixtureA.getBody().getUserData() == null)) {
return;
}
if (bodyB.getUserData() == null) {
return;
}
final boolean bIsGround = bodyB.getUserData().equals("ground");
final Object tempData = fixtureA.getBody().getUserData();
if (fixtureA.getUserData().equals("foot") && bIsGround) {
((Player) tempData).setFooterCollidingCount(((Player) tempData).getFooterCollidingCount() + 1);
// System.out.println("MyContactListener - playerIsOnGround = true");
} else
if (fixtureA.getUserData().equals("outerFootRight")) {
((Player) tempData).incrOuterFootRightCount();
} else
if (fixtureA.getUserData().equals("outerFootLeft")) {
((Player) tempData).incrOuterFootLeftCount();
}
}
示例5: checkWallCollision
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public static void checkWallCollision(final Fixture fixtureA, final Body bodyB, final boolean set) {
if ((fixtureA.getUserData() == null) || (fixtureA.getBody().getUserData() == null)) {
return;
}
if (bodyB.getUserData() == null) {
return;
}
final Object tempData = fixtureA.getBody().getUserData();
final boolean bIsGround = bodyB.getUserData().equals("ground");
if (fixtureA.getUserData().equals("wall") && bIsGround) {
if (set) {
((Player) tempData).incrWall();
} else {
((Player) tempData).decrWall();
}
}
}
示例6: checkHeadCollision
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public static void checkHeadCollision(final Fixture fixtureA, final Body bodyB, final boolean set) {
if ((fixtureA.getUserData() == null) || (fixtureA.getBody().getUserData() == null)) {
return;
}
if (bodyB.getUserData() == null) {
return;
}
final Object tempData = fixtureA.getBody().getUserData();
final boolean bIsGround = bodyB.getUserData().equals("ground");
if (fixtureA.getUserData().equals("head") && bIsGround) {
if (set) {
((Player) tempData).incrHead();
} else {
((Player) tempData).decrHead();
}
}
}
示例7: checkEndFootCollision
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public static void checkEndFootCollision(final Fixture fixtureA, final Body bodyB) {
if ((fixtureA.getUserData() == null) || (fixtureA.getBody().getUserData() == null)) {
return;
}
if (bodyB.getUserData() == null) {
return;
}
final Object tempData = fixtureA.getBody().getUserData();
final boolean bIsGround = bodyB.getUserData().equals("ground");
if (fixtureA.getUserData().equals("foot") && bIsGround) {
((Player) tempData).setFooterCollidingCount(((Player) tempData).getFooterCollidingCount() - 1);
// System.out.println("MyContactListener - playerIsOnGround = true");
} else
if (fixtureA.getUserData().equals("outerFootRight")) {
((Player) tempData).decrOuterFootRightCount();
} else
if (fixtureA.getUserData().equals("outerFootLeft")) {
((Player) tempData).decrOuterFootLeftCount();
}
}
示例8: RaycastHit
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public RaycastHit(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
this.collider = (Component) fixture.getUserData();
JGameObject gameObject = collider.getGameObject();
this.transform = gameObject.getTransform();
this.point = point;
this.normal = normal;
this.rigidbody = gameObject.getComponent(Rigidbody.class);
this.fraction = fraction;
}
示例9: beginContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public void beginContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
if (fixA.getUserData() instanceof Player || fixB.getUserData() instanceof Player) {
Fixture objA = fixA.getUserData() instanceof Player ? fixA : fixB;
((Player) objA.getUserData()).setTouching(true);
collision.play();
}
}
示例10: endContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public void endContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
if (fixA.getUserData() instanceof Player || fixB.getUserData() instanceof Player) {
Fixture objA = fixA.getUserData() instanceof Player ? fixA : fixB;
((Player) objA.getUserData()).setTouching(false);
}
}
示例11: removeBox2DBodies
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private void removeBox2DBodies () {
if (!box2DWorld.isLocked()) {
Array<Body> bodies = new Array<Body>();
box2DWorld.getBodies(bodies);
for (int i = 0; i < bodies.size; i++)
if (bodies.get(i).getUserData() != null && ((UserData)bodies.get(i).getUserData()).isFlaggedForDelete)
box2DWorld.destroyBody(bodies.get(i));
else
for (Fixture f : bodies.get(i).getFixtureList())
if (f.getUserData() != null && ((UserData)f.getUserData()).isFlaggedForDelete)
box2DWorld.destroyBody(bodies.get(i));
}
}
示例12: beginContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public void beginContact(Contact contact) {
Fixture fa = contact.getFixtureA();
Fixture fb = contact.getFixtureB();
if (fa == null || fb == null) return;
if (fa.getUserData() != null && fa.getUserData().equals("foot")) {
numFootContacts++;
}
if (fb.getUserData() != null && fb.getUserData().equals("foot")) {
numFootContacts++;
}
if (fa.getUserData() != null && fa.getUserData().equals("crystal")) {
bodiesToRemove.add(fa.getBody());
}
if (fb.getUserData() != null && fb.getUserData().equals("crystal")) {
bodiesToRemove.add(fb.getBody());
}
if (fa.getUserData() != null && fa.getUserData().equals("spike")) {
playerDead = true;
}
if (fb.getUserData() != null && fb.getUserData().equals("spike")) {
playerDead = true;
}
}
示例13: endContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public void endContact(Contact contact) {
Fixture fa = contact.getFixtureA();
Fixture fb = contact.getFixtureB();
if (fa == null || fb == null) return;
if (fa.getUserData() != null && fa.getUserData().equals("foot")) {
numFootContacts--;
}
if (fb.getUserData() != null && fb.getUserData().equals("foot")) {
numFootContacts--;
}
}
示例14: processCollision
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public void processCollision(Fixture colliderA, Fixture colliderB, boolean collisionSignal) {
if (colliderA.isSensor() && !colliderB.isSensor()) {
Integer indexEntityA = (Integer) colliderA.getBody().getUserData();
Integer indexEntityB = (Integer) colliderB.getBody().getUserData();
String tagSensorA = (String) colliderA.getUserData();
Body bodyB = colliderB.getBody();
for (Fixture fixture : bodyB.getFixtureList()) {
if(fixture.isSensor()) return;
}
if (indexEntityA != null && indexEntityB != null && tagSensorA != null) {
GameEntity entityA = Indexed.getInteractiveEntity(indexEntityA);
GameEntity entityB = Indexed.getInteractiveEntity(indexEntityB);
if (entityA != null && entityB != null && tagSensorA != null) {
for (SensorEntity entity : sensorGroup.getEntities()) {
if (entity.getLink().ownerEntity == indexEntityA) {
NearSensor sensor = entity.getNearSensor();
if (sensor.targetTag != null && entityB.getTags().values.contains(sensor.targetTag)) {
if (collisionSignal) {
if (tagSensorA.equals("NearSensor")) {
sensor.distanceContactList.add(indexEntityB);
if (entity.getLink().sensorReference.contains("RadialGravity")) {
bodyB.setGravityScale(0);
bodyB.resetMassData();
}
} else if (tagSensorA.equals("ResetNearSensor")) {
sensor.resetDistanceContactList.add(indexEntityB);
}
} else {
if (tagSensorA.equals("NearSensor")) {
sensor.distanceContactList.remove(indexEntityB);
if (entity.getLink().sensorReference.contains("RadialGravity")) {
bodyB.setGravityScale(1);
bodyB.resetMassData();
}
} else if (tagSensorA.equals("ResetNearSensor")) {
sensor.resetDistanceContactList.remove(indexEntityB);
}
}
}
}
}
}
}
}
}
示例15: isContacted
import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
/**
* 判断两个物体是否接触
*
* @param fixtureA 夹具A
* @param fixtureB 夹具B
* @param strA A物体名称
* @param strB B物体名称
* @return 接触返回true 未接触返回false
*/
public static boolean isContacted(Fixture fixtureA, Fixture fixtureB, String strA, String strB) {
if (fixtureA.getUserData() != null && fixtureA.getUserData().equals(strA) &&
fixtureB.getUserData() != null && fixtureB.getUserData().equals(strB)) {
return true;
}
return false;
}