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


Java CircleShape.setRadius方法代码示例

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


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

示例1: testNewWorld

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
@Test
public void testNewWorld() {
    World world = new World(new Vec2(0, -9.8f));

    BodyDef axisDef = new BodyDef();
    axisDef.type = BodyType.STATIC;
    axisDef.position = new Vec2(3, 3);
    Body axis = world.createBody(axisDef);

    CircleShape axisShape = new CircleShape();
    axisShape.setRadius(0.02f);
    axisShape.m_p.set(0, 0);

    //FixtureDef axisFixture = new FixtureDef();
    //axisFixture.shape = axisShape;
    //axis.createFixture(axisFixture);

}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:19,代码来源:JBox2DTest.java

示例2: createShape

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
protected static Shape createShape(PhysicsBodyShape shape, float width, float height, float x, float y, float rotation) {
	switch( shape ) {
		case BOX:
			PolygonShape box = new PolygonShape();
			box.setAsBox(width / 2f * BOX2D_SCALE_FACTOR, height / 2f * BOX2D_SCALE_FACTOR, toBox2dCS(x,y), rotation);
			return box;
			
		case CIRCLE:
			assert( Math.abs(height-width)<0.00001 );
			CircleShape circle = new CircleShape();
			circle.setRadius(height/2 * BOX2D_SCALE_FACTOR);
			circle.m_p.x = x*BOX2D_SCALE_FACTOR;
			circle.m_p.y = y*BOX2D_SCALE_FACTOR;
			return circle;
			
		default:
			throw new RuntimeException("Unsupported Shape-Type: "+shape);
	}
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:20,代码来源:Box2dPhysicsBody.java

示例3: initPhysics

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
public void initPhysics(){
	BodyDef bodyDef = new BodyDef();
	bodyDef.type =  BodyType.DYNAMIC;
	bodyDef.fixedRotation = true;
	bodyDef.position.set(position.x, position.y);
	body = PhysicsManager.createBody(bodyDef);
	CircleShape dynamicCircle = new CircleShape();
	dynamicCircle.setRadius(range);
	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.shape = dynamicCircle;
	fixtureDef.density = 0.3f;
	fixtureDef.friction = 0.0f;
	fixtureDef.isSensor = true;
	body.createFixture(fixtureDef);
	PhysicsDataStructure s = new PhysicsDataStructure(this, GameBodyType.TRIGGERZONE); 
	body.setUserData(s);
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:18,代码来源:TriggerZone.java

示例4: initPhysics

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
/**
 * Initialize the physics body
 * 
 * @param w
 *            the physics world
 */
public void initPhysics(){
	BodyDef bodyDef = new BodyDef();
	bodyDef.type = btype;
	bodyDef.fixedRotation = true;
	bodyDef.position.set(position.x, position.y);
	body = PhysicsManager.createBody(bodyDef);
	CircleShape dynamicCircle = new CircleShape();
	dynamicCircle.setRadius(this.halfSize.x);
	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.shape = dynamicCircle;
	fixtureDef.density = 0.3f;
	fixtureDef.friction = 0.0f;
	body.createFixture(fixtureDef);
	PhysicsDataStructure s = new PhysicsDataStructure(this, gbtype); 
	body.setUserData(s);
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:23,代码来源:DynamicEntity.java

示例5: getCircleBody

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
public Body getCircleBody(Vector2f position, float radius, BodyType type){
	BodyDef def = new BodyDef();
	def.position.set(position.x, position.y);
	
	Body body = world.createBody(def);
	
	CircleShape circle = new CircleShape();
	circle.setRadius(radius);
	body.createFixture(circle, 1.0f);
	
	body.setType(type);
	
	return body;
}
 
开发者ID:tek256,项目名称:LD38,代码行数:15,代码来源:Physics.java

示例6: initAxis

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
private void initAxis() {
    BodyDef axisDef = new BodyDef();
    axisDef.type = BodyType.STATIC;
    axisDef.position = new Vec2(3, 3);
    axis = world.createBody(axisDef);

    CircleShape axisShape = new CircleShape();
    axisShape.setRadius(0.02f);
    axisShape.m_p.set(0, 0);

    FixtureDef axisFixture = new FixtureDef();
    axisFixture.shape = axisShape;
    axis.createFixture(axisFixture);
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:15,代码来源:JBox2DSimulation.java

示例7: EllipsePhysics

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
public EllipsePhysics(float x, float y, float radius, BodyType type, Ellipse ellipse, PhysicsInformation information)
{
	super(information);
	BodyDef def = new BodyDef();
	def.position.set(new Vec2(x, y));
	def.type = type;
	this.body = Game.world.createBody(def);
	CircleShape shape = new CircleShape();
	shape.setRadius(radius/2);
	FixtureDef fixture = new FixtureDef();
	fixture.density = 1;
	fixture.shape = shape;
	fixture.setUserData(ellipse);
	body.createFixture(fixture);
}
 
开发者ID:Joshuagollaher,项目名称:HawkEngine,代码行数:16,代码来源:EllipsePhysics.java

示例8: createCircleShape

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
private CircleShape createCircleShape(View view, PhysicsConfig config) {
    CircleShape circle = new CircleShape();
    if (config.radius == -1) {
        config.radius = Math.max(view.getWidth() / 2, view.getHeight() / 2);
    }
    circle.setRadius(pixelsToMeters(config.radius));
    return circle;
}
 
开发者ID:Leon1809,项目名称:Android-Physics-Box2D-Native,代码行数:9,代码来源:Physics.java

示例9: addSphere

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
/**
 * Adds a sphere Fixture to this object. You don't have to do anything with
 * the returned Fixture unless you need it for something.
 * 
 * Position is relative to the center of this object.
 * 
 * Radius is simple enough.
 * 
 * Friction is also pretty straightforward. Goes above 1.
 */
public Fixture addSphere(Vec2 pos, float radius, float friction, float restitution, boolean sensor) {
	CircleShape shape2 = new CircleShape();
	
	shape2.m_p.set(new Vector2(pos.x, pos.y));
	shape2.setRadius(radius);
	Fixture fix = body.createFixture(shape2, 1);
	fix.setFriction(friction);
	
	return fix;
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:21,代码来源:PhysicsObject2D.java

示例10: Ball

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
public Ball(float headingAngle, Body ballBody) {
	super(ballBody);

	Vec2 velocityVector = TrigHelpers.PolarToVec2(headingAngle, 25);
	m_body.setLinearVelocity(velocityVector);
	CircleShape ballShape = new CircleShape();
	ballShape.setRadius(0.5f);

	m_body.createFixture(ballShape, 10);
	m_body.getFixtureList().setRestitution(1.1f);
	m_body.getFixtureList().setFriction(0.5f);
	m_body.setUserData(this);
}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:14,代码来源:Ball.java

示例11: Bullet

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
public Bullet(float headingAngle,
		      Body bulletBody) {
	
	super(bulletBody);

	Vec2 velocityVector = TrigHelpers.PolarToVec2(headingAngle, 50);
	m_body.setLinearVelocity(velocityVector);
	CircleShape bulletShape = new CircleShape();
	bulletShape.setRadius(0.1f);
	
	m_body.createFixture(bulletShape, 50);
	
	m_body.setUserData(this);
}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:15,代码来源:Bullet.java

示例12: makeShape

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
@Override
protected void makeShape(World world) {
	CircleShape circleShape = new CircleShape();
	circleShape.setRadius(m_radius);
	
       m_body.createFixture(circleShape, this.m_density);		
       m_body.getFixtureList().setRestitution(this.m_restitution);
       m_body.getFixtureList().setFriction(this.m_friction);
}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:10,代码来源:ManagedCircleModel.java

示例13: setShape

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
public void setShape() {
    CircleShape circle = new CircleShape();
    circle.setRadius(0.1f);
    fixture = body.createFixture(circle, 0);
    fixture.setFriction(2F);
    fixture.setDensity(0.5F);
    body.setLinearDamping(0.2F);
}
 
开发者ID:Rekkyn,项目名称:projectradon,代码行数:9,代码来源:Bullet.java

示例14: setShape

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
@Override
public void setShape() {
    CircleShape circle = new CircleShape();
    circle.setRadius(0.1f);
    fixture = body.createFixture(circle, 0);
    fixture.setFriction(2F);
    fixture.setDensity(0.3F);
    body.setLinearDamping(1F);
}
 
开发者ID:Rekkyn,项目名称:projectradon,代码行数:10,代码来源:Pellet.java

示例15: init

import org.jbox2d.collision.shapes.CircleShape; //导入方法依赖的package包/类
@Override
public void init() {
    super.init();
    
    CircleShape circle = new CircleShape();
    circle.setRadius(0.5f);
    fixture = body.createFixture(circle, 0);
    fixture.setFriction(0.2F);
    
    body.setBullet(true);
    body.setFixedRotation(true);
    body.setUserData(this);
    fixture.setRestitution(restitution);;
}
 
开发者ID:Rekkyn,项目名称:projectradon,代码行数:15,代码来源:Character.java


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