本文整理汇总了Java中com.badlogic.gdx.physics.box2d.CircleShape.setRadius方法的典型用法代码示例。如果您正苦于以下问题:Java CircleShape.setRadius方法的具体用法?Java CircleShape.setRadius怎么用?Java CircleShape.setRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.CircleShape
的用法示例。
在下文中一共展示了CircleShape.setRadius方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCircle
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
/** Creates a circle object with the given position and radius. Resitution defaults to 0.6. */
public static Body createCircle(World world, float x, float y, float radius, boolean isStatic) {
CircleShape sd = new CircleShape();
sd.setRadius(radius);
FixtureDef fdef = new FixtureDef();
fdef.shape = sd;
fdef.density = 1.0f;
fdef.friction = 0.3f;
fdef.restitution = 0.6f;
BodyDef bd = new BodyDef();
bd.allowSleep = true;
bd.position.set(x, y);
Body body = world.createBody(bd);
body.createFixture(fdef);
if (isStatic) {
body.setType(BodyDef.BodyType.StaticBody);
}
else {
body.setType(BodyDef.BodyType.DynamicBody);
}
return body;
}
示例2: createRopeTipBody
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private Body createRopeTipBody()
{
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.linearDamping = 0.5f;
Body body = world.createBody(bodyDef);
FixtureDef circleDef = new FixtureDef();
CircleShape circle = new CircleShape();
circle.setRadius(1.0f/PTM_RATIO);
circleDef.shape = circle;
circleDef.density = 10.0f;
// Since these tips don't have to collide with anything
// set the mask bits to zero
circleDef.filter.maskBits = 0x01; //0;
body.createFixture(circleDef);
return body;
}
示例3: createSpinner
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public static Body createSpinner(World world) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(Constants.SPINNER_POSITIONS);
Body body = world.createBody(bodyDef);
CircleShape circle = new CircleShape();
circle.setRadius(Constants.SPINNER_SIZE);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = circle;
fixtureDef.density = Constants.SPENNER_DENSITY;
fixtureDef.friction = 0f;
fixtureDef.restitution = 0.45f;
body.createFixture(fixtureDef);
circle.dispose();
return body;
}
示例4: createStaticAttackBody
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
/**
* Erzeugt automatisch einen Kreis als statischen Trigger.
*
* @see AttackHandler#createAttackFixture(Body, Shape)
*
* @param position der Mittelpunkt des Kreises
* @param radius der Radius des Kreises
*/
public void createStaticAttackBody(Vector2 position, float radius)
{
CircleShape circle = new CircleShape();
circle.setPosition(new Vector2(position.x, position.y).scl(Physics.MPP));
circle.setRadius(radius * Physics.MPP);
BodyDef triggerDef = new BodyDef();
triggerDef.type = BodyDef.BodyType.StaticBody;
Body trigger = manager.getPhysicalWorld().createBody(triggerDef);
createAttackFixture(trigger, circle);
circle.dispose();
}
示例5: initBall
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private void initBall() {
float radius = 26;
mBall = new Circle(0.f, 0.f, radius);
mBallTextureRegion = new TextureRegion(new Texture(Gdx.files.internal("ball.png")));
// create physics body
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(mBall.x, mBall.y);
CircleShape ballShape = new CircleShape();
ballShape.setRadius(mBall.radius - 2.f);
mBallBody = mWorld.createBody(bodyDef);
mBallBody.setUserData(new BodyUserDate(BODY_USER_DATA_TYPE_BALL));
Fixture fixture = mBallBody.createFixture(ballShape, 0.5f);
fixture.setFriction(BALL_FRICTION_BASE);
fixture.setRestitution(0.4f);
ballShape.dispose();
}
示例6: definePlayer
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public void definePlayer(){
BodyDef bdef = new BodyDef();
bdef.position.set(100 / QuackHack.PPM, 1500 / QuackHack.PPM); // Mario start position
bdef.type = BodyDef.BodyType.DynamicBody;
b2body = world.createBody(bdef);
FixtureDef fdef = new FixtureDef();
CircleShape shape = new CircleShape();
shape.setRadius(64 / QuackHack.PPM);
fdef.filter.categoryBits = QuackHack.MARIO_BIT;
fdef.filter.maskBits = QuackHack.DEFAULT_BIT;
fdef.friction = 0;
fdef.density = 0.1f;
fdef.shape = shape;
b2body.createFixture(fdef);
b2body.createFixture(fdef).setUserData(this);
}
示例7: Food
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public Food(World world, float x, float y, int size, float toGive) {
super(x, y);
color = new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
outline = Advio.instance.darker(color);
BodyDef bd = new BodyDef();
bd.type = BodyType.KinematicBody;
bd.position.set(x, y);
CircleShape shape = new CircleShape();
shape.setRadius(size);
FixtureDef fd = new FixtureDef();
fd.density = 0.1f;
fd.shape = shape;
fd.friction = 0.1f;
// fd.filter.groupIndex = Advio.GROUP_BEINGS;
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("food").add("toGive", toGive));
shape.dispose();
}
示例8: Player
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public Player(World world, float x, float y) {
super(x, y);
this.world = world;
this.graphicsSize = 10;
color = new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
outline = Advio.instance.darker(color);
BodyDef bd = new BodyDef();
bd.type = BodyType.DynamicBody;
bd.position.set(x, y);
CircleShape shape = new CircleShape();
shape.setRadius(50);
FixtureDef fd = new FixtureDef();
fd.density = 0.0f;
fd.shape = shape;
fd.friction = 0.1f;
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("player"));
shape.dispose();
// size * 2.25f
}
示例9: Enemy
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public Enemy(World world, float x, float y, int size) {
super(x, y);
this.world = world;
this.graphicsSize = 0.1f;
color = new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
outline = Advio.instance.darker(color);
BodyDef bd = new BodyDef();
bd.type = BodyType.DynamicBody;
bd.position.set(x, y);
CircleShape shape = new CircleShape();
shape.setRadius(size);
FixtureDef fd = new FixtureDef();
fd.density = 0.0f;
fd.shape = shape;
fd.friction = 0.1f;
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("enemy").add("body", body));
shape.dispose();
}
示例10: apply
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
@Override
public void apply () {
Body body = ((Rigidbody)getParent().getComponentByType(ComponentType.Rigidbody)).getBody();
FixtureDef fixtureDef = new FixtureDef();
CircleShape shape = new CircleShape();
shape.setPosition(new Vector2(x, y));
shape.setRadius(radius);
fixtureDef.density = density;
fixtureDef.friction = friction;
fixtureDef.isSensor = isSensor;
fixtureDef.restitution = restitution;
fixtureDef.shape = shape;
if (fixture != null) {
dispose();
fixture = null;
((Rigidbody)getParent().getComponentByType(ComponentType.Rigidbody)).apply();
rebuildAll();
getParent().transform.setRotation(getParent().transform.getRotation());
return;
}
fixture = body.createFixture(fixtureDef);
fixture.setFilterData(filter);
UserData userdata = new UserData();
userdata.component = (Rigidbody)getParent().getComponentByName("Rigidbody");
fixture.setUserData(userdata);
}
示例11: createEllipse
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
/**
*
* @param world
* @param ellipseObject
* @param density
* @param friction
* @param restitution
*/
private void createEllipse(World world, EllipseMapObject ellipseObject, float density, float friction, float restitution){
Ellipse circle = ellipseObject.getEllipse();
CircleShape shape = new CircleShape();
shape.setRadius(circle.width / 2f / SupaBox.PPM);
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(new Vector2((circle.x + circle.width / 2f) / SupaBox.PPM, (circle.y + circle.width / 2f) / SupaBox.PPM));
Body body = world.createBody(bodyDef);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = density;
fixtureDef.friction = friction;
fixtureDef.restitution = restitution;
body.createFixture(fixtureDef);
shape.dispose();
}
示例12: defineItem
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
@Override
protected void defineItem() {
BodyDef bdef = new BodyDef();
bdef.position.set(getX(), getY());
bdef.type = BodyDef.BodyType.DynamicBody;
b2body = world.createBody(bdef);
FixtureDef fdef = new FixtureDef();
CircleShape shape = new CircleShape();
shape.setRadius(6 / MarioBros.PPM);
fdef.filter.categoryBits = MarioBros.ITEM_BIT;
fdef.filter.maskBits = MarioBros.MARIO_BIT | MarioBros.OBJECT_BIT |
MarioBros.GROUND_BIT | MarioBros.COIN_BIT | MarioBros.BRICK_BIT | MarioBros.ENEMY_BIT;
fdef.shape = shape;
b2body.createFixture(fdef).setUserData(this);
}
示例13: createCircle
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public static Body createCircle() {
if (!BodyFactory.initialized) {
throw new IllegalStateException("You must initialize BodyFactory before using its functions");
}
final BodyDef testBodyDef2 = new BodyDef();
testBodyDef2.position.set(2, 3);
testBodyDef2.type = BodyDef.BodyType.DynamicBody;
testBodyDef2.fixedRotation = true;
final Body body2 = BodyFactory.world.createBody(testBodyDef2);
final CircleShape testShape2 = new CircleShape();
testShape2.setRadius(1f);
final FixtureDef testFixtureDef2 = new FixtureDef();
testFixtureDef2.shape = testShape2;
testFixtureDef2.density = 25f;
testFixtureDef2.friction = 1f;
testFixtureDef2.restitution = 0;
body2.createFixture(testFixtureDef2);
final MassData md = body2.getMassData();
md.mass = 80; // kg
body2.setMassData(md);
// System.out.println("circle - mass: " + body2.getMassData().mass + " density: " + body2.getFixtureList().get(0).getDensity());
testShape2.dispose();
return body2;
}
示例14: Ball
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public Ball(World world, float x, float y) {
BodyDef bodyDef = new BodyDef();
FixtureDef fixtureDef = new FixtureDef();
this.world = world;
// body definition
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.set(x, y);
// ball shape
CircleShape ballShape = new CircleShape();
ballShape.setRadius(RADIUS);
// fixture definition
fixtureDef.shape = ballShape;
fixtureDef.friction = 0;
fixtureDef.restitution = 1;
//fixtureDef.density = 0;
body = world.createBody(bodyDef);
fixture = body.createFixture(fixtureDef);
ballShape.dispose();
}
示例15: circleSensor
import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public EntityBuilder circleSensor (float radius) {
CircleShape shape = new CircleShape();
shape.setRadius(radius);
PhysicsComponent physics = Components.PHYSICS.get(entity);
if (physics == null) {
physicsBody(DEFAULT_BODY);
}
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.isSensor = true;
fixtureDef.shape = shape;
physics.getBody().createFixture(fixtureDef);
return this;
}