本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);;
}