本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Fixture类的典型用法代码示例。如果您正苦于以下问题:Java Fixture类的具体用法?Java Fixture怎么用?Java Fixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fixture类属于com.badlogic.gdx.physics.box2d包,在下文中一共展示了Fixture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processBallContacts
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
/**
* Called after Box2D world step method, to notify FieldElements that the ball collided with.
*/
void processBallContacts() {
for(int i=0; i<contactedBalls.size(); i++) {
Ball ball = contactedBalls.get(i);
Fixture f = contactedFixtures.get(i);
FieldElement element = bodyToFieldElement.get(f.getBody());
if (element!=null) {
element.handleCollision(ball, f.getBody(), this);
if (delegate!=null) {
delegate.processCollision(this, element, f.getBody(), ball);
}
if (element.getScore()!=0) {
this.gameState.addScore(element.getScore());
audioPlayer.playScore();
}
}
}
}
示例2: endContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的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);
}
}
示例3: beginContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的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);
}
示例4: endContact
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的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);
}
示例5: step
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
/**
* Function called in the game loop, responsible for updating the fluid.
*/
public void step() {
for (Fixture fixture : fixtures) {
if (fixture.getBody().isAwake()) {
/* Create clipPolygon */
List<Vector2> clipPolygon = getFixtureVertices(fixture);
/* Create subjectPolygon */
List<Vector2> subjectPolygon;
if (isFluidFixed) {
subjectPolygon = fluidVertices;
} else
subjectPolygon = getFixtureVertices(fluidSensor);
/* Get intersection polygon */
List<Vector2> clippedPolygon = PolygonIntersector.clipPolygons(
subjectPolygon, clipPolygon);
if (!clippedPolygon.isEmpty()) {
applyForces(fixture, clippedPolygon.toArray(new Vector2[0]));
}
}
}
}
示例6: circleToSquare
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
/**
* Because the algorithm is based on vertices, and the circles do not have vertices, we create a square around it.
* @param fixture Circle fixture
* @return A square instead of the circle
*/
private static PolygonShape circleToSquare(Fixture fixture) {
Vector2 position = fixture.getBody().getLocalCenter();
float x = position.x;
float y = position .y;
float radius = fixture.getShape().getRadius();
PolygonShape octagon = new PolygonShape();
Vector2[] vertices = new Vector2[4];
vertices[0] = new Vector2(x-radius, y+radius);
vertices[1]= new Vector2(x+radius, y+radius);
vertices[2]= new Vector2(x-radius, y-radius);
vertices[3]= new Vector2(x+radius, y-radius);
octagon.set((Vector2[]) vertices);
return octagon;
}
示例7: Water
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
/**
* Constructor that allows to specify if there is an effect of waves and splash particles.
* @param waves Specifies whether the object will have waves
* @param splashParticles Specifies whether the object will have splash particles
*/
public Water(boolean waves, boolean splashParticles) {
this.waves = waves;
this.splashParticles = splashParticles;
this.fixturePairs = new HashSet<Pair<Fixture, Fixture>>();
this.setDebugMode(false);
if (waves) {
textureWater = new TextureRegion(new Texture(Gdx.files.internal("water.png")));
polyBatch = new PolygonSpriteBatch();
}
if (splashParticles) {
textureDrop = new Texture(Gdx.files.internal("drop.png"));
spriteBatch = new SpriteBatch();
particles = new ArrayList<Particle>();
}
shapeBatch = new ShapeRenderer();
shapeBatch.setColor(0, 0.5f, 1, 1);
}
示例8: 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;
}
}
}
示例9: 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--;
}
}
示例10: initBall
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
private void initBall() {
float radius = 26;
mBall = new Circle(0.f, 0.f, radius);
mBallTextureRegion = new TextureRegion(new Texture(Gdx.files.internal("ball.png")));
// create physics body
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(mBall.x, mBall.y);
CircleShape ballShape = new CircleShape();
ballShape.setRadius(mBall.radius - 2.f);
mBallBody = mWorld.createBody(bodyDef);
mBallBody.setUserData(new BodyUserDate(BODY_USER_DATA_TYPE_BALL));
Fixture fixture = mBallBody.createFixture(ballShape, 0.5f);
fixture.setFriction(BALL_FRICTION_BASE);
fixture.setRestitution(0.4f);
ballShape.dispose();
}
示例11: raycastPoint
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
public static List<RaycastHit> raycastPoint(final Vector2 pointToTest) {
final List<RaycastHit> hits = new ArrayList<RaycastHit>();
Vector2 end = pointToTest.add(new Vector2(1, 1));
//TODO move to static single object
physic.physicWorld.QueryAABB(new QueryCallback() {
@Override
public boolean reportFixture(Fixture fixture) {
if (fixture.testPoint(pointToTest)) {
hits.add(new RaycastHit(fixture, pointToTest));
}
return true;
}
}, pointToTest.x < end.x ? pointToTest.x : end.x, pointToTest.y < end.y ? pointToTest.y : end.y,
pointToTest.x > end.x ? pointToTest.x : end.x, pointToTest.y > end.y ? pointToTest.y : end.y);
return hits;
}
示例12: emptyDestroyList
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
public static void emptyDestroyList()
{
if (!world.isLocked())
{
while(toDestroyList.size > 0)
{
if (toDestroyList.get(0).getBody() != null)
{
Body b = toDestroyList.get(0).getBody();
Array<Fixture> fixes = new Array<Fixture>();
world.getFixtures(fixes);
if (fixes.contains(b.getFixtureList().first(), false)) {
world.destroyBody(b);
}
}
toDestroyList.get(0).finalCleanup();
toDestroyList.get(0).removeFromWorldLayers(lh);
toDestroyList.removeValue(toDestroyList.get(0), true);
}
}
}
示例13: die
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
public void die(DeathType death)
{
if(alive)
{
if (grabbed != null)
{
stopGrabbing(false);
}
gameWorld.startRespawnClock(this);
Fixture f = body.getFixtureList().get(0);
Filter fi = f.getFilterData();
fi.categoryBits = BodyFactory.CAT_DECEASED;
fi.maskBits = BodyFactory.MASK_DECEASED;
f.setFilterData(fi);
body.getFixtureList().set(0, f);
super.die(death);
}
}
示例14: swapWorldLayers
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
public void swapWorldLayers(LayerHandler lh)
{
removeFromWorldLayers(lh);
lh.addEntityToLayer(this, LayerHandler.ground);
swapped = true;
Fixture f = body.getFixtureList().get(0);
Filter fi = f.getFilterData();
fi.categoryBits = BodyFactory.CAT_IMPASSABLE;
fi.maskBits = BodyFactory.MASK_SHERIFF_GROUND;
f.setFilterData(fi);
body.getFixtureList().set(0, f);
canFire = false;
TimerManager.addTimer(swapTimer);
}
示例15: testPlayerMud
import com.badlogic.gdx.physics.box2d.Fixture; //导入依赖的package包/类
public void testPlayerMud(GameEntity geA, GameEntity geB, Fixture fA, Fixture fB, boolean start)
{
if (geA instanceof Player || geB instanceof Player)
{
if (geA instanceof Player && fA.getDensity() == BodyFactory.HIT_BOX_DEN ||
geB instanceof Player && fB.getDensity() == BodyFactory.HIT_BOX_DEN)
{
if (geB.getType() == EntityType.MUD)
{
handlePlayerTerrain(geA, geB, start);
}
else if (geA.getType() == EntityType.MUD)
{
handlePlayerTerrain(geB, geA, start);
}
}
}
}