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


Java Fixture.getUserData方法代码示例

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

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

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

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

                }
            }
        }
    }
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:27,代码来源:RadarSensorSystem.java

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

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

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

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

示例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;
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:10,代码来源:RaycastHit.java

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

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

}
 
开发者ID:edwardszczepanski,项目名称:QuackHack,代码行数:12,代码来源:WorldContactListener.java

示例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));
	}
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:14,代码来源:SceneHandler.java

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

    }
 
开发者ID:awwong1,项目名称:BlockBunny,代码行数:30,代码来源:BBContactListener.java

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

    }
 
开发者ID:awwong1,项目名称:BlockBunny,代码行数:16,代码来源:BBContactListener.java

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

                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:52,代码来源:NearSensorSystem.java

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


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