當前位置: 首頁>>代碼示例>>Java>>正文


Java Circle類代碼示例

本文整理匯總了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;
}
 
開發者ID:LetsCoders,項目名稱:MassiveTanks,代碼行數:19,代碼來源:BulletObjectFactory.java

示例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);
}
 
開發者ID:Pheelbert,項目名稱:cretion,代碼行數:28,代碼來源:ProjectilePhysicsComponent.java

示例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);
}
 
開發者ID:LSFN,項目名稱:-archived-Nebula-Java,代碼行數:13,代碼來源:Asteroid.java


注:本文中的org.dyn4j.geometry.Circle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。