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


Java Fixture.isSensor方法代码示例

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


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

示例1: handleFootContact

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的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

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

示例3: beginContact

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的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

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

示例5: 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);
	BulletComponent bullet = App.engine.mappers.bullet.get(entity);
	ChildComponent child = App.engine.mappers.child.get(entity);
	
	//Iterate over all touching fixtures, checking to see if they have 
	// health, and deal damage as necessary
	Array<Fixture> fixturesTouching = App.engine.systems.physics.getFixturesTouching(physics);
	for (Fixture f : fixturesTouching){
		//Should have no effect on sensors
		if (f.isSensor()) continue;
		PhysicsComponent p = (PhysicsComponent) f.getBody().getUserData();
		if (p == null) continue;
		Entity dealer = (child == null) ? entity : child.parentEntity;
		dealDamage(dealer,p.ownerEntity,bullet.damage,physics.getRotation());
	}
	
	//disable bullet after colliding with anything
	if (physics.getCollisionNormal() > 0) {
		physics.setFilter(CollisionBits.Effects,CollisionBits.Mask_Effects);
		entity.remove(BulletComponent.class);
		//logger.debug("Entity #" + entity.getId() + ": damage disabled");
	}	
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:27,代码来源:DamageSystem.java

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

示例7: fromFixture

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
public void fromFixture(Fixture f){
	shapeModel = new ShapeModel(f.getShape());
	Filter filterData = f.getFilterData();
	filter.categoryBits = filterData.categoryBits;
	filter.maskBits = filterData.maskBits;
	filter.groupIndex = filterData.groupIndex;
	sensor = f.isSensor();
	density = f.getDensity();
	friction = f.getFriction();
	restitution = f.getRestitution();
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:12,代码来源:FixtureModel.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: itemWithNonSensor

import com.badlogic.gdx.physics.box2d.Fixture; //导入方法依赖的package包/类
private static void itemWithNonSensor(final Fixture fixture, final Object userData) {
	if ((userData instanceof Item) && !fixture.isSensor()) {
		// ((Item) userData).reset();
		// System.out.println(userData + " with non-sensor " + fixture.getBody().getUserData());
	}
}
 
开发者ID:TheElk205,项目名称:KillTheNerd,代码行数:7,代码来源:MyContactListener.java

示例10: 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.isSensor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。