本文整理匯總了Java中org.dyn4j.geometry.Circle類的典型用法代碼示例。如果您正苦於以下問題:Java Circle類的具體用法?Java Circle怎麽用?Java Circle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Circle類屬於org.dyn4j.geometry包,在下文中一共展示了Circle類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildBody
import org.dyn4j.geometry.Circle; //導入依賴的package包/類
private Body buildBody(final TankObject shootingTank) {
Body body = new Body();
Axis2D facingDirection = shootingTank.getFacingDirection();
Position tankPosition = shootingTank.getPosition();
Circle circle = new Circle(1);
BodyFixture bodyFixture = new BodyFixture(circle);
bodyFixture.setSensor(true);
LOGGER.info("velocity x,y {}.{}", facingDirection.getX() * DEFAULT_BULLET_SPEED, facingDirection.getY() * DEFAULT_BULLET_SPEED);
body.getTransform().setTranslation(
tankPosition.getX() + facingDirection.getX() * DEFAULT_OFFSET,
tankPosition.getY() + facingDirection.getY() * DEFAULT_OFFSET);
body.setLinearVelocity(facingDirection.getX() * DEFAULT_BULLET_SPEED,
facingDirection.getY() * DEFAULT_BULLET_SPEED);
body.addFixture(bodyFixture);
body.setBullet(true);
body.setMass();
return body;
}
示例2: setup
import org.dyn4j.geometry.Circle; //導入依賴的package包/類
public void setup() {
positionComponent = entity.getComponent(PositionComponent.class);
DimensionComponent dimensionComponent = entity.getComponent(DimensionComponent.class);
body = new Body();
double projectileRadius = ((double) dimensionComponent.getWidth() / 3);
double convertedWorldRadius = PhysicsHelper.toWorld(projectileRadius);
Circle circle = Geometry.createCircle(convertedWorldRadius);
BodyFixture circleFixture = new BodyFixture(circle);
circleFixture.setFilter(new ProjectileFilter(shooter, entity));
body.addFixture(circleFixture);
body.setMass(Mass.Type.FIXED_ANGULAR_VELOCITY);
body.setBullet(true);
body.setGravityScale(0);
Vector2 projectilePosition = new Vector2(positionComponent.getX(), positionComponent.getY());
Vector2 convertedWorldPosition = PhysicsHelper.toWorld(projectilePosition);
body.translate(convertedWorldPosition);
body.setLinearVelocity(new Vector2(direction.x * 999999999, direction.y * 999999999));
world.addBody(body);
}
示例3: Asteroid
import org.dyn4j.geometry.Circle; //導入依賴的package包/類
public Asteroid(World world, Vector2 startPos) {
this.asteroidBody = new Body();
Convex asteroidConvex = new Circle(1.0);
BodyFixture fixture = new BodyFixture(asteroidConvex);
fixture.setDensity(1.0);
fixture.setFriction(0.0);
fixture.setRestitution(0.0);
this.asteroidBody.addFixture(fixture);
this.asteroidBody.setMass();
this.asteroidBody.translate(startPos);
world.addBody(this.asteroidBody);
}