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


Java BodyType.StaticBody方法代码示例

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


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

示例1: createStaticBoxBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
/**
    * Create static body from a TiledObject Refer the box2d manual to
    * understand the static body
    * 
    * @param o
    *            TiledObject
    */
   public Body createStaticBoxBody(float x, float y, float width, float height) {
BodyDef groundBodyDef = new BodyDef();
groundBodyDef.type = BodyType.StaticBody;

// transform into box2d
x = x * WORLD_TO_BOX;

// get position-y from map
y = Gdx.graphics.getHeight() - y;
// transform into box2d
y = y * WORLD_TO_BOX;

groundBodyDef.position.set(x, y);
Body groundBody = world.createBody(groundBodyDef);
PolygonShape polygon = new PolygonShape();
((PolygonShape) polygon).setAsBox(width * WORLD_TO_BOX / 2, height
	* WORLD_TO_BOX / 2);
groundBody.createFixture(polygon, 0.0f);
groundBody.setUserData("static");
return groundBody;
   }
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:29,代码来源:PhysicsManager.java

示例2: createStaticCircleBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
/**
    * Create static body from a TiledObject Refer the box2d manual to
    * understand the static body
    * 
    * @param o
    *            TiledObject
    */
   public Body createStaticCircleBody(float x, float y, float radius) {
BodyDef groundBodyDef = new BodyDef();
groundBodyDef.type = BodyType.StaticBody;
// transform into box2d
x = x * WORLD_TO_BOX;
// get position-y of object from map
y = Gdx.graphics.getHeight() - y;
// transform into box2d
y = y * WORLD_TO_BOX;

groundBodyDef.position.set(x, y);
Body groundBody = world.createBody(groundBodyDef);
CircleShape shape = new CircleShape();
((CircleShape) shape).setRadius(radius * WORLD_TO_BOX / 2);
groundBody.createFixture(shape, 0.0f);
groundBody.setUserData("static");
return groundBody;
   }
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:26,代码来源:PhysicsManager.java

示例3: createTempBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public Body createTempBody(float x, float y, FixtureDef fixtureDef) {
// Dynamic Body
BodyDef bodyDef = new BodyDef();
if (box2dDebug)
    bodyDef.type = BodyType.StaticBody;
else
    bodyDef.type = BodyType.DynamicBody;

// transform into box2d
x = x * WORLD_TO_BOX;
y = y * WORLD_TO_BOX;

bodyDef.position.set(x, y);

Body body = world.createBody(bodyDef);

Shape shape = new CircleShape();
((CircleShape) shape).setRadius(1 * WORLD_TO_BOX);

if (fixtureDef == null)
    throw new GdxRuntimeException("fixtureDef cannot be null!");
fixtureDef.shape = shape;
body.createFixture(fixtureDef);
return body;
   }
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:26,代码来源:PhysicsManager.java

示例4: createStaticBoxBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
/**
 * Create static body from a TiledObject Refer the box2d manual to
 * understand the static body
 * 
 * @param o
 *            TiledObject
 */
public Body createStaticBoxBody(float x, float y, float width, float height) {
	BodyDef groundBodyDef = new BodyDef();
	groundBodyDef.type = BodyType.StaticBody;

	// transform into box2d
	x = x * WORLD_TO_BOX;

	// get position-y from map
	y = tileMapRenderer.getMapHeightUnits() - y;
	// transform into box2d
	y = y * WORLD_TO_BOX;

	groundBodyDef.position.set(x, y);
	Body groundBody = world.createBody(groundBodyDef);
	PolygonShape polygon = new PolygonShape();
	((PolygonShape) polygon).setAsBox(width * WORLD_TO_BOX / 2, height
			* WORLD_TO_BOX / 2);
	groundBody.createFixture(polygon, 0.0f);
	groundBody.setUserData("static");
	return groundBody;
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:29,代码来源:PhysicsTiledScene.java

示例5: createStaticCircleBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
/**
 * Create static body from a TiledObject Refer the box2d manual to
 * understand the static body
 * 
 * @param o
 *            TiledObject
 */
public Body createStaticCircleBody(float x, float y, float radius) {
	BodyDef groundBodyDef = new BodyDef();
	groundBodyDef.type = BodyType.StaticBody;
	// transform into box2d
	x = x * WORLD_TO_BOX;
	// get position-y of object from map
	y = tileMapRenderer.getMapHeightUnits() - y;
	// transform into box2d
	y = y * WORLD_TO_BOX;

	groundBodyDef.position.set(x, y);
	Body groundBody = world.createBody(groundBodyDef);
	CircleShape shape = new CircleShape();
	((CircleShape) shape).setRadius(radius * WORLD_TO_BOX / 2);
	groundBody.createFixture(shape, 0.0f);
	groundBody.setUserData("static");
	return groundBody;
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:26,代码来源:PhysicsTiledScene.java

示例6: createTempBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public Body createTempBody(float x, float y, FixtureDef fixtureDef) {
	// Dynamic Body
	BodyDef bodyDef = new BodyDef();
	if (box2dDebug)
		bodyDef.type = BodyType.StaticBody;
	else
		bodyDef.type = BodyType.DynamicBody;

	// transform into box2d
	x = x * WORLD_TO_BOX;
	y = y * WORLD_TO_BOX;

	bodyDef.position.set(x, y);

	Body body = world.createBody(bodyDef);

	Shape shape = new CircleShape();
	((CircleShape) shape).setRadius(1 * WORLD_TO_BOX);

	if (fixtureDef == null)
		throw new GdxRuntimeException("fixtureDef cannot be null!");
	fixtureDef.shape = shape;
	body.createFixture(fixtureDef);
	return body;
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:26,代码来源:PhysicsTiledScene.java

示例7: createBody

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

    final PolygonShape shape = new PolygonShape();
    shape.setAsBox(Block.HALF_SIZE, Block.HALF_SIZE);
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.isSensor = true;
    fixtureDef.shape = shape;
    fixtureDef.filter.categoryBits = Box2DUtil.CAT_BLOCK;
    fixtureDef.filter.maskBits = Box2DUtil.MASK_BLOCK;
    final Body body = box2d.getWorld().createBody(bodyDef);
    body.createFixture(fixtureDef);
    shape.dispose();
    return body;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:19,代码来源:Bonus.java

示例8: createBody

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

    final PolygonShape shape = new PolygonShape();
    shape.setAsBox(HALF_SIZE, HALF_SIZE);
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.restitution = 1f;
    fixtureDef.friction = 0f;
    fixtureDef.shape = shape;
    fixtureDef.filter.categoryBits = Box2DUtil.CAT_BLOCK;
    fixtureDef.filter.maskBits = Box2DUtil.MASK_BLOCK;
    final Body body = box2d.getWorld().createBody(bodyDef);
    body.createFixture(fixtureDef);
    shape.dispose();
    return body;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:20,代码来源:Block.java

示例9: createBody

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

    final ChainShape shape = new ChainShape();
    final float w = Box2DUtil.WIDTH * 2f / 5f, h = Box2DUtil.HEIGHT * 2f / 5f;
    shape.createLoop(new float[] { -w, -h, -w, h, w, h, w, -h });
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.restitution = 0.9f;
    fixtureDef.friction = 0.2f;
    fixtureDef.shape = shape;
    fixtureDef.filter.categoryBits = Box2DUtil.CAT_BOUNDS;
    fixtureDef.filter.maskBits = Box2DUtil.MASK_BLOCK;
    final Body body = box2d.getWorld().createBody(bodyDef);
    body.createFixture(fixtureDef);
    return body;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:20,代码来源:BoundsEntity.java

示例10: create

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public void create(){
	init = true;
	bdef.type = BodyType.StaticBody;
	bdef.position.set(x, y);
	
	ChainShape cs = new ChainShape();
	Vector2[] v = new Vector2[5];
	
	v[0] = new Vector2(-TILE_SIZE / 2 / PPM, -TILE_SIZE / 2 / PPM);
	v[1] = new Vector2(-TILE_SIZE / 2 / PPM, TILE_SIZE / 2 / PPM);
	v[2] = new Vector2(TILE_SIZE / 2 / PPM, TILE_SIZE / 2 / PPM);
	v[3] = new Vector2(TILE_SIZE / 2 / PPM, -TILE_SIZE / 2 / PPM);
	v[4] = new Vector2(-Vars.TILE_SIZE / 2 / Vars.PPM, -Vars.TILE_SIZE / 2 / Vars.PPM);
	cs.createChain(v);
	
	fdef.friction = .25f;
	fdef.shape = cs;
	fdef.filter.categoryBits = Vars.BIT_GROUND;
	fdef.filter.maskBits = Vars.BIT_LAYER1 | Vars.BIT_PLAYER_LAYER | Vars.BIT_LAYER3 | Vars.BIT_BATTLE;
	fdef.isSensor = false;
	body = world.createBody(bdef);
	body.createFixture(fdef).setUserData("ground");
	body.setUserData(this);
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:25,代码来源:Ground.java

示例11: Player

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public Player(World world, float x, float y, float width, float height) {
	
	BodyDef bodyDef = new BodyDef();
	bodyDef.type = BodyType.StaticBody;
	bodyDef.position.set(x, y);
	this.width = width;
	this.height = height;
	
	
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(width, height);

	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.shape = shape;
					
	body = world.createBody(bodyDef);
	fixture = body.createFixture(fixtureDef);
	
	shape.dispose();
}
 
开发者ID:CODA-Masters,项目名称:Pong-Tutorial,代码行数:21,代码来源:Player.java

示例12: createRectangle

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
/**
 * 
 * @param world
 * @param rectangleObject
 * @param density
 * @param friction
 * @param restitution
 */
private void createRectangle(World world, RectangleMapObject rectangleObject, float density, float friction, float restitution){
	Rectangle rect = rectangleObject.getRectangle();
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(rect.width / SupaBox.PPM / 2f, rect.height / SupaBox.PPM / 2f);
	
	BodyDef bodyDef = new BodyDef();
	bodyDef.type = BodyType.StaticBody;
	bodyDef.position.set(new Vector2((rect.x + rect.width / 2f) / SupaBox.PPM, (rect.y + rect.height / 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();
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:30,代码来源:BodyBuilder.java

示例13: createEllipse

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的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();
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:30,代码来源:BodyBuilder.java

示例14: ladCls

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
private void ladCls() {
	
	BodyDef colision = new BodyDef();
	colision.position.set(getX()/GameWorld.units,(getY()+getHeight()/2)/GameWorld.units);
	colision.type = BodyType.StaticBody;
	colision.fixedRotation  = true;
	
	PolygonShape shape =new PolygonShape(); 
	shape.setAsBox(getWidth()/GameWorld.units/2,(getHeight()/GameWorld.units/2));

	FixtureDef fixDef = new FixtureDef();
	fixDef.shape = shape;
       
       fixDef.filter.categoryBits = GameWorld.BIT_LADRILLOS;
	fixDef.filter.maskBits = GameWorld.BIT_JUGADOR | GameWorld.BIT_ENEMIGOS;
	fixDef.isSensor = false;
	
	
	ladrillo = GameWorld.mundo.createBody(colision);
	ladrillo.createFixture(fixDef).setUserData("ladrillo");
	ladrillo.setGravityScale(0);
	ladrillo.isBullet();
	
}
 
开发者ID:programacion2VideojuegosUM2015,项目名称:practicos,代码行数:25,代码来源:Ladrillo.java

示例15: createPhysicsWorld

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
private void createPhysicsWorld() {

		world = new World(new Vector2(0, 0), true);
		
		float halfWidth = viewportWidth / 2f;
		ChainShape chainShape = new ChainShape();
		chainShape.createLoop(new Vector2[] {
				new Vector2(-halfWidth, 0f),
				new Vector2(halfWidth, 0f),
				new Vector2(halfWidth, viewportHeight),
				new Vector2(-halfWidth, viewportHeight) });
		BodyDef chainBodyDef = new BodyDef();
		chainBodyDef.type = BodyType.StaticBody;
		groundBody = world.createBody(chainBodyDef);
		groundBody.createFixture(chainShape, 0);
		chainShape.dispose();
		createBoxes();
	}
 
开发者ID:libgdx,项目名称:box2dlights,代码行数:19,代码来源:Box2dLightTest.java


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