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


Java Fixture.getBody方法代码示例

本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Fixture.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java Fixture.getBody方法的具体用法?Java Fixture.getBody怎么用?Java Fixture.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.physics.box2d.Fixture的用法示例。


在下文中一共展示了Fixture.getBody方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportRayFixture

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
final public float reportRayFixture(Fixture fixture, Vector2 point,
		Vector2 normal, float fraction) {
	
	if ((globalFilterA != null) && !globalContactFilter(fixture))
		return -1;
	
	if ((filterA != null) && !contactFilter(fixture))
		return -1;
	
	if (ignoreBody && fixture.getBody() == getBody())
		return -1;
	
	// if (fixture.isSensor())
	// return -1;
	
	mx[m_index] = point.x;
	my[m_index] = point.y;
	f[m_index] = fraction;
	return fraction;
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:22,代码来源:Light.java

示例2: fixtureToColor

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
/**
 * Translates b2d Fixture to appropriate color, depending on body state/type
 * Modify to suit your needs
 * @param fixture
 * @return
 */
private static Color fixtureToColor(Fixture fixture) {
	if (fixture.isSensor()) {
		return Color.PINK;
	} else {
		Body body = fixture.getBody();
		if (!body.isActive()) {
			return Color.BLACK;
		} else {
			if (!body.isAwake()) {
				return Color.RED;
			} else {
				switch (body.getType()) {
				case StaticBody:
					return Color.CYAN;
				case KinematicBody:
					return Color.WHITE;
				case DynamicBody:
				default:
					return Color.GREEN;
				}
			}
		}
	}
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:31,代码来源:DebugRenderer.java

示例3: reportFixture

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
public boolean reportFixture(Fixture fixture) {
	Body b = fixture.getBody();
	if(!found.contains(b, true)){
		found.add(b);
	}
	return true;
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:9,代码来源:QueryAABBCallback.java

示例4: getEntity

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private Entity getEntity(Fixture fixture) {
    Body body = fixture.getBody();
    BodyData bodyData = (BodyData)body.getUserData();
    if (bodyData == null) {
        return null;
    }

    return bodyData.entity;
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:10,代码来源:CollisionListener.java

示例5: testPoint

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private void testPoint(Fixture fixture, PointerState<Vector2,Vector3> pointerState) {
    if (!fixture.testPoint(pointerState.coordinates.x, pointerState.coordinates.y))
        return;
    Integer index = (Integer) fixture.getBody().getUserData();
    GameEntity entity =  Indexed.getInteractiveEntity(index);
    if(entity.isDraggable()) {
        jointDef.bodyB = fixture.getBody();
        jointDef.target.set(pointerState.coordinates.x, pointerState.coordinates.y);
        joints[pointerState.pointer] = (MouseJoint) physics.createJoint(jointDef);
    }
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:12,代码来源:InputManagerGDX.java

示例6: checkContact

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private boolean checkContact(Contact contact) {
    // ignore not touching contacts
    if (!contact.isTouching()) return false;

    Fixture fixtureA = contact.getFixtureA();
    if (fixtureA == null) return false;

    Fixture fixtureB = contact.getFixtureB();
    if (fixtureB == null) return false;

    Body bodyA = fixtureA.getBody();
    Body bodyB = fixtureB.getBody();

    String nameA = (String) bodyA.getUserData();
    String nameB = (String) bodyB.getUserData();

    if (nameA == null || nameB == null) {               // nameless bodies, check if sound needs to be played
        checkCollisionSound(contact, bodyA, bodyB);
        return false;
    } else if (nameA.equals(ObjectName.EDGE_SENSOR_NAME) || nameB.equals(ObjectName.EDGE_SENSOR_NAME)) {    // check edges
        Log.d(TAG, "onUpdate: OFF THE EDGE");

        setBallOut();

        return true;
    } else if (nameA.equals(ObjectName.SINKHOLE_NAME) || nameB.equals(ObjectName.SINKHOLE_NAME)) {  // check sinkhole
        Log.d(TAG, "onUpdate: SINKHOLE");

        setLevelComplete();

        return true;
    }

    return false;
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:36,代码来源:GameLevelController.java

示例7: reportRayFixture

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public float reportRayFixture(Fixture f,Vector2 p,Vector2 n,float fra){
	if (f.isSensor() && ignoreSensors) return -1;
	fixture = f;
	body = f.getBody();
	physics = (PhysicsComponent)body.getUserData();
	point = p;
	normal = n;
	fraction = fra;
	return fra;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:11,代码来源:RayCast.java

示例8: 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

示例9: processEntity

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
@Override
protected void processEntity(Entity entity, float deltaTime) {
	PhysicsComponent physics = App.engine.mappers.physics.get(entity);
	HealthComponent health = App.engine.mappers.health.get(entity);
	StickyComponent sticky = App.engine.mappers.sticky.get(entity);
	
	float collisionForce = physics.getCollisionNormal();
	
	//Sticky projectiles
	if (sticky != null && sticky.enabled){
		Fixture stickyFixture = physics.getFixture(sticky.fixtureName);
		if (stickyFixture != null){
			
			boolean colliding = getContactCount(stickyFixture) > 0;
			
			Array<Fixture> touchingFixtures = getFixturesTouching(stickyFixture);
			for (Fixture f : touchingFixtures){
				if (f.isSensor()) colliding = false;
				else {
					WeldJointDef jd = new WeldJointDef();
					Body b1 = f.getBody(),
					     b2 = stickyFixture.getBody();
					jd.initialize(b1,b2,b2.getWorldCenter());
					world.createJoint(jd);
					sticky.enabled = false;
					break;
				}
			}
			
			if (!colliding)	physics.setRotation(physics.getLinearVelocity().angle());

		}
	}
	
	//Collision Damage
	if (health != null && collisionForce >= health.collisionDamageThreshold){
		float dmg = collisionForce - health.collisionDamageThreshold;
		App.engine.systems.damage.dealDamage(entity,dmg);
		logger.debug(String.format("Collision damage: Entity#%d ; Force=%f ; Dmg=%f",
									entity.getId(),collisionForce,dmg));
	}
	physics.clearCollisionNormal();
	
	/*
	//Anything outside of the world bounds is destroyed
	if (!App.engine.entityBounds.contains(physics.getPosition()) &&
			entity != App.engine.getLevel().getEntity()){
		logger.debug("Destroy Entity #" + entity.getId() + ": outside of world bounds.");
		App.engine.removeEntity(physics.ownerEntity);
	}
	*/

}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:54,代码来源:PhysicsSystem.java


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