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


Java CircleShape.setPosition方法代码示例

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


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

示例1: 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();
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:25,代码来源:AttackHandler.java

示例2: 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);
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:27,代码来源:CircleCollider.java

示例3: createPlayer

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private Body createPlayer () {
	BodyDef def = new BodyDef();
	def.type = BodyType.DynamicBody;
	Body box = world.createBody(def);

	PolygonShape poly = new PolygonShape();
	poly.setAsBox(0.45f, 1.4f);
	playerPhysicsFixture = box.createFixture(poly, 1);
	poly.dispose();

	CircleShape circle = new CircleShape();
	circle.setRadius(0.45f);
	circle.setPosition(new Vector2(0, -1.4f));
	playerSensorFixture = box.createFixture(circle, 0);
	circle.dispose();

	box.setBullet(true);

	return box;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:21,代码来源:Box2DCharacterControllerTest.java

示例4: createSteeringEntity

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public Box2dSteeringEntity createSteeringEntity (World world, TextureRegion region, boolean independentFacing, int posX, int posY) {

		CircleShape circleChape = new CircleShape();
		circleChape.setPosition(new Vector2());
		int radiusInPixels = (int)((region.getRegionWidth() + region.getRegionHeight()) / 4f);
		circleChape.setRadius(Box2dSteeringTest.pixelsToMeters(radiusInPixels));

		BodyDef characterBodyDef = new BodyDef();
		characterBodyDef.position.set(Box2dSteeringTest.pixelsToMeters(posX), Box2dSteeringTest.pixelsToMeters(posY));
		characterBodyDef.type = BodyType.DynamicBody;
		Body characterBody = world.createBody(characterBodyDef);

		FixtureDef charFixtureDef = new FixtureDef();
		charFixtureDef.density = 1;
		charFixtureDef.shape = circleChape;
		charFixtureDef.filter.groupIndex = 0;
		characterBody.createFixture(charFixtureDef);

		circleChape.dispose();

		return new Box2dSteeringEntity(region, characterBody, independentFacing, Box2dSteeringTest.pixelsToMeters(radiusInPixels));
	}
 
开发者ID:libgdx,项目名称:gdx-ai,代码行数:23,代码来源:Box2dSteeringTest.java

示例5: ExplodeBall

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public ExplodeBall(Level level, long id) {
	super(level, id);
	thisID = id;
	mName = "lightbulb";
	mTex = "data/"+Game.get().getBodyEditorLoader().getImagePath(mName);
	Vector2 origin = new Vector2();
	mBody = makeBody(mName, 64, BodyType.DynamicBody, origin, false);
	((CompositeDrawable)mDrawable).mDrawables.add(new BodySprite(mBody, origin, mTex));

	CircleShape circle = new CircleShape();
	circle.setPosition(new Vector2(0,0));
	circle.setRadius(detectRadius);
	FixtureDef fd = new FixtureDef();
	fd.shape = circle;
	fd.isSensor = true;
	mSensorBall = mBody.createFixture(fd);
	explodeTime = 180;
	
	mExplodeTimer = new Timer();
	mExplodeTimer.setTimer(explodeTime);
	mExplodeTimer.unpause();
	
	setProp("Density", 0.3);
}
 
开发者ID:underclocker,项目名称:Blob-Game,代码行数:25,代码来源:ExplodeBall.java

示例6: ImplodeBall

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public ImplodeBall(Level level, long id) {
	super(level, id);
	thisID = id;
	mName = "lightbulb";
	mTex = "data/"+Game.get().getBodyEditorLoader().getImagePath(mName);
	Vector2 origin = new Vector2();
	mBody = makeBody(mName, 64, BodyType.DynamicBody, origin, false);
	((CompositeDrawable)mDrawable).mDrawables.add(new BodySprite(mBody, origin, mTex));

	CircleShape circle = new CircleShape();
	circle.setPosition(new Vector2(0,0));
	circle.setRadius(detectRadius);
	FixtureDef fd = new FixtureDef();
	fd.shape = circle;
	fd.isSensor = true;
	mSensorBall = mBody.createFixture(fd);
	explodeTime = 180;
	
	mExplodeTimer = new Timer();
	mExplodeTimer.setTimer(explodeTime);
	mExplodeTimer.unpause();
	
	setProp("Density", 0.3);
}
 
开发者ID:underclocker,项目名称:Blob-Game,代码行数:25,代码来源:ImplodeBall.java

示例7: createCircleBody

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
/**
 * Erlaubt es den Unterklassen möglichst einfach einen runden Box2D Körper zu erstellen.
 *
 * @param position die Startposition des Body
 * @param radius der Radius der Form
 * @return ein Box2D Körper
 */
protected Body createCircleBody(Vector2 position, float radius)
{
    CircleShape circle = new CircleShape();

    circle.setPosition(Vector2.Zero);
    circle.setRadius(radius * Physics.MPP);

    return createEntityBody(position, circle);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:17,代码来源:BaseEntity.java

示例8: createCircle

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
/**
 * Erzeugt aus einem EllipseMapObject ein CircleShape.
 *
 * Ellipsen werden von Box2D nicht unterstützt, Tiled erzeugt aber auch bei Kreisen EllipseMapObjects.
 * Deshalb ermittelt diese Methode den kleineren Radius und benutzt diesen um einen Kreis zu erstellen.
 *
 * @param ellipseObject das MapObject
 * @return die entsprechende Form
 */
public static CircleShape createCircle(EllipseMapObject ellipseObject)
{
    Ellipse ellipse = ellipseObject.getEllipse();
    CircleShape circle = new CircleShape();

    circle.setPosition(new Vector2(ellipse.x + ellipse.width * 0.5f, ellipse.y + ellipse.height * 0.5f).scl(Physics.MPP));
    circle.setRadius(Math.min(ellipse.width, ellipse.height) * 0.5f * Physics.MPP);

    return circle;
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:20,代码来源:PhysicsTileMapBuilder.java

示例9: createBody

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
@Override
protected Body createBody(final Box2DService box2d) {
    final BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyType.DynamicBody;
    bodyDef.fixedRotation = true;
    bodyDef.linearDamping = 2f;
    final Body body = box2d.getWorld().createBody(bodyDef);

    final CircleShape shape = new CircleShape();
    shape.setRadius(1f);
    shape.setPosition(new Vector2(0f, 0.3f));

    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = shape;
    fixtureDef.filter.categoryBits = getCatBits();
    fixtureDef.filter.maskBits = getMaskBits();
    fixtureDef.density = 0.4f;
    fixtureDef.restitution = 0.3f;
    body.createFixture(fixtureDef);
    shape.dispose();

    final PolygonShape coreShape = new PolygonShape();
    coreShape.setAsBox(0.5f, 0.5f);
    fixtureDef.shape = coreShape;
    fixtureDef.filter.categoryBits = Box2DUtil.CAT_MINION;
    fixtureDef.filter.maskBits = Box2DUtil.MASK_MINION_CORE;
    body.createFixture(fixtureDef);
    coreShape.dispose();

    return body;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:32,代码来源:Minion.java

示例10: addHeadFixture

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private static void addHeadFixture(final Body body) {
    final CircleShape shape = new CircleShape();
    shape.setRadius(48f / 18f);
    shape.setPosition(new Vector2(0f, 0.3f));
    body.createFixture(getFixtureDef(shape));
    shape.dispose();
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:8,代码来源:Player.java

示例11: loadShape

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private Shape loadShape(JsonValue root) {
	Shape shape = null;
	JsonValue shapeValue = root.get("shape");
	
	if (shapeValue == null) {
		return shape;
	}
	
	String type = shapeValue.getString("type");

	float x = shapeValue.getFloat("centerX", 0.0f);
	float y = shapeValue.getFloat("centerY", 0.0f);
	
	if (type.equals("circle")) {
		logger.info("loading cicle shape");
		CircleShape circle = new CircleShape();
		circle.setPosition(new Vector2(x, y));
		circle.setRadius(shapeValue.getFloat("radius", 1.0f));
		shape = circle;
	}
	else if (type.equals("polygon")) {
		logger.info("loading polygon shape");
		PolygonShape polygon = new PolygonShape();
		polygon.setAsBox(shapeValue.getFloat("width", 1.0f),
						 shapeValue.getFloat("height", 1.0f),
						 new Vector2(x, y),
						 0.0f);
		shape = polygon;
	}
	else {
		logger.error("shape unknown " + type);
	}
	
	
	return shape;
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:37,代码来源:PhysicsDataLoader.java

示例12: defineBigMario

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private void defineBigMario() {
    Vector2 currentPosition = b2body.getPosition();
    world.destroyBody(b2body);

    BodyDef bdef = new BodyDef();
    bdef.position.set(currentPosition.add(0, 10 / MarioBros.PPM));
    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.MARIO_BIT;
    fdef.filter.maskBits = MarioBros.GROUND_BIT | MarioBros.COIN_BIT | MarioBros.ITEM_BIT
            | MarioBros.BRICK_BIT | MarioBros.ENEMY_BIT | MarioBros.OBJECT_BIT | MarioBros.ENEMY_HEAD_BIT;
    fdef.shape = shape;

    b2body.createFixture(fdef).setUserData(this);

    shape.setPosition(new Vector2(0, -14 / MarioBros.PPM));
    b2body.createFixture(fdef).setUserData(this);

    EdgeShape head = new EdgeShape();
    head.set(new Vector2(-2 / MarioBros.PPM, 7 / MarioBros.PPM), new Vector2(2 / MarioBros.PPM, 7 / MarioBros.PPM));
    fdef.shape = head;
    fdef.filter.categoryBits = MarioBros.MARIO_HEAD_BIT;
    fdef.isSensor = true;

    b2body.createFixture(fdef).setUserData(this);

    timeToDefineBigMario = false;
}
 
开发者ID:lbalmaceda,项目名称:libgdx_mario,代码行数:34,代码来源:Mario.java

示例13: circleFixtureDef

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public static FixtureDef circleFixtureDef(float radius, Vector2 position, float density, float friction, float restitution, boolean isSensor){
	CircleShape s = new CircleShape();
	s.setPosition(position);
	s.setRadius(radius);
	FixtureDef fd = fixtureDef(density,friction,restitution,s,isSensor);
	return fd;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:8,代码来源:Box2dHelper.java

示例14: circleFixture

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public static Fixture circleFixture(Body b, float radius, float x, float y, float density, float friction, float restitution, boolean isSensor){
	CircleShape s = new CircleShape();
	s.setPosition(new Vector2(x,y));
	s.setRadius(radius);
	FixtureDef fd = fixtureDef(density,friction,restitution,s,isSensor);
	Fixture f = b.createFixture(fd);
	s.dispose();
	return f;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:10,代码来源:Box2dHelper.java

示例15: getCircle

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
private Shape getCircle(CircleMapObject circleObject) {
	Circle circle = circleObject.getCircle();
	CircleShape circleShape = new CircleShape();
	circleShape.setRadius(circle.radius / GameWorld.units);
	circleShape.setPosition(new Vector2(circle.x / GameWorld.units, circle.y / GameWorld.units));
	return circleShape;
}
 
开发者ID:programacion2VideojuegosUM2015,项目名称:practicos,代码行数:8,代码来源:GeneradorNivel.java


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