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


Java BodyType.STATIC属性代码示例

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


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

示例1: Wall

Wall(Box2DProcessing box2d, float x_, float y_, float w_, float h_) {
    this.box2d = box2d;
    x = x_;
    y = y_;
    w = w_;
    h = h_;

    PolygonShape sd = new PolygonShape();
    float box2dW = box2d.scalarPixelsToWorld(w / 2);
    float box2dH = box2d.scalarPixelsToWorld(h / 2);
    sd.setAsBox(box2dW, box2dH);

    BodyDef bd = new BodyDef();
    bd.type = BodyType.STATIC;
    bd.position.set(box2d.coordPixelsToWorld(x, y));
    b = box2d.createBody(bd);

    // Attached the shape to the body using a Fixture
    b.createFixture(sd, 1);
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:20,代码来源:Wall.java

示例2: testNewWorld

@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,代码行数:18,代码来源:JBox2DTest.java

示例3: Ground

public Ground(Texture texture) {
	super(new Vec2(WINDOW_WIDTH/2,WINDOW_HEIGHT-texture.getTexture().height/2),texture);
	//Body def
   	BodyDef bd = new BodyDef();
   	bd.type = BodyType.STATIC;
   	bd.position.set(Public.box2d.coordPixelsToWorld(WINDOW_WIDTH/2,WINDOW_HEIGHT-texture.getTexture().height/2) );
   	bd.setUserData("PhysicalGameObject,Ground");
   	//Create body
       body = Public.box2d.createBody(bd);
   	//Creat Shape
       PolygonShape ps = new PolygonShape();
       ps.setAsBox(Public.box2d.scalarPixelsToWorld(Public.p.width*100),-Public.box2d.scalarPixelsToWorld(-texture.getTexture().height/2) );
       //Fixture
       FixtureDef fd = new FixtureDef();
       fd.shape = ps;
       fd.density = 1f;
       fd.friction = 0.3f;
       fd.restitution = 0.15f;
       body.createFixture(fd);
       
}
 
开发者ID:Error1000,项目名称:processingGameEngine,代码行数:21,代码来源:Ground.java

示例4: init

/**
 * Sets up the actual physics part of this helper class.
 * 
 * As always call super or else this definition has no use and you get crashing.
 */
@Override
public void init(Scene scene) {
	BodyDef def = new BodyDef();
	if (isDynamic) {
		def.type = BodyType.DYNAMIC;
	}
	else {
		def.type = BodyType.STATIC;
	}
	
	body = scene.world2D.createBody(def);
	body.setUserData(this);
	
	if (isBullet) {
		body.setBullet(true);
	}
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:22,代码来源:PhysicsObject2D.java

示例5: init

@Override
public void init(Scene scene) {
	super.init(scene);
	ObjectGroup colliderLayer = (ObjectGroup) map.getLayer(2);
	BodyDef de = new BodyDef();
	de.type = BodyType.STATIC;
	
	Iterator<MapObject> iter = colliderLayer.getObjects();
	while (iter.hasNext()) {
		MapObject ob = iter.next();
		
		float rwidth = (float)ob.getWidth() / 16f;
		float rheight = (float)ob.getHeight() / 16f;
		
		float xpos = ((float)ob.getX() / 16f) + (rwidth / 2f);
		float ypos = ((float)ob.getY() / 16f) + (rheight / 2f);
		
		this.addCube(vec2(xpos, (mapHeight - 1) - ypos + 1), vec2(rwidth / 2, rheight / 2), 0.2f, false);
	}
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:20,代码来源:Grid2D.java

示例6: initPhysicsBody

@Override Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  // height of the portal contact box
  float boxHeight = getHeight() / 12f;
  float boxWidth = getWidth() * 0.75f;
  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[4];
  polygon[0] = new Vec2(-boxWidth/2f, getHeight()/2f - boxHeight);
  polygon[1] = new Vec2(boxWidth/2f, getHeight()/2f - boxHeight);
  polygon[2] = new Vec2(boxWidth/2f, getHeight()/2f);
  polygon[3] = new Vec2(-boxWidth/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.8f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:24,代码来源:Portal.java

示例7: initPhysicsBody

@Override Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[4];
  polygon[0] = new Vec2(-getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[1] = new Vec2(getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[2] = new Vec2(getWidth()/2f, getHeight()/2f);
  polygon[3] = new Vec2(-getWidth()/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.8f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:21,代码来源:Block.java

示例8: initPhysicsBody

@Override
Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[3];
  polygon[0] = new Vec2(getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[1] = new Vec2(getWidth()/2f, getHeight()/2f);
  polygon[2] = new Vec2(-getWidth()/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.9f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:21,代码来源:BlockLeftRamp.java

示例9: initPhysicsBody

@Override
Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[4];
  polygon[0] = new Vec2(-getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[1] = new Vec2(getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[2] = new Vec2(getWidth()/2f, getHeight()/2f);
  polygon[3] = new Vec2(-getWidth()/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 1.0f;
  fixtureDef.restitution = 0.3f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:22,代码来源:BlockGel.java

示例10: initPhysicsBody

@Override
Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[3];
  polygon[0] = new Vec2(-getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[1] = new Vec2(getWidth()/2f, getHeight()/2f);
  polygon[2] = new Vec2(-getWidth()/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.9f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:21,代码来源:BlockRightRamp.java

示例11: setType

/**
 * Sets the simulation type of the physical body. It can be one of the values
 * {@link Behavior#STATIC}, {@link Behavior#DYNAMIC}, or {@link Behavior#KINEMATIC}.
 *
 * @param type The desired simulation type
 *
 * @see Behavior
 */
public final void setType(Behavior type) {
    if (body != null) {
        switch (type) {
            case DYNAMIC:
                body.m_type = BodyType.DYNAMIC;
                break;
            case STATIC:
                body.m_type = BodyType.STATIC;
                break;
            default:
                body.m_type = BodyType.KINEMATIC;
                break;
        }
    } else desc.type = type;
}
 
开发者ID:hessan,项目名称:artenus,代码行数:23,代码来源:PhysicalBody.java

示例12: initPhysicsBody

@Override
Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  // height of the portal contact box
  float boxHeight = getHeight() / 12f;
  float boxWidth = getWidth() * 0.75f;
  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[4];
  polygon[0] = new Vec2(-boxWidth/2f, getHeight()/2f - boxHeight);
  polygon[1] = new Vec2(boxWidth/2f, getHeight()/2f - boxHeight);
  polygon[2] = new Vec2(boxWidth/2f, getHeight()/2f);
  polygon[3] = new Vec2(-boxWidth/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.8f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:25,代码来源:Portal.java

示例13: initPhysicsBody

@Override
Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.STATIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  PolygonShape polygonShape = new PolygonShape();
  Vec2[] polygon = new Vec2[4];
  polygon[0] = new Vec2(-getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[1] = new Vec2(getWidth()/2f, -getHeight()/2f + getTopOffset());
  polygon[2] = new Vec2(getWidth()/2f, getHeight()/2f);
  polygon[3] = new Vec2(-getWidth()/2f, getHeight()/2f);
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.8f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:22,代码来源:Block.java

示例14: createTopAndBottomBounds

private void createTopAndBottomBounds() {
    int boundSize = Math.round(boundsSize);
    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyType.STATIC;
    PolygonShape box = new PolygonShape();
    int boxWidth = (int) pixelsToMeters(width);
    int boxHeight = (int) pixelsToMeters(boundSize);
    box.setAsBox(boxWidth, boxHeight);
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = box;
    fixtureDef.density = 0.5f;
    fixtureDef.friction = 0.3f;
    fixtureDef.restitution = 0.5f;

    fixtureDef.userData = R.id.physics_layout_bound_top;
    bodyDef.position.set(0, -boxHeight);
    Body topBody = world.createBody(bodyDef);
    topBody.createFixture(fixtureDef);
    bounds.add(topBody);

    fixtureDef.userData = R.id.physics_layout_body_bottom;
    bodyDef.position.set(0, pixelsToMeters(height) + boxHeight);
    Body bottomBody = world.createBody(bodyDef);
    bottomBody.createFixture(fixtureDef);
    bounds.add(bottomBody);
}
 
开发者ID:Jawnnypoo,项目名称:PhysicsLayout,代码行数:26,代码来源:Physics.java

示例15: createLeftAndRightBounds

private void createLeftAndRightBounds() {
    int boundSize = Math.round(boundsSize);
    int boxWidth = (int) pixelsToMeters(boundSize);
    int boxHeight = (int) pixelsToMeters(height);
    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyType.STATIC;
    PolygonShape box = new PolygonShape();
    box.setAsBox(boxWidth, boxHeight);
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = box;
    fixtureDef.density = 0.5f;
    fixtureDef.friction = 0.3f;
    fixtureDef.restitution = 0.5f;

    fixtureDef.userData = R.id.physics_layout_body_left;
    bodyDef.position.set(-boxWidth, 0);
    Body leftBody = world.createBody(bodyDef);
    leftBody.createFixture(fixtureDef);
    bounds.add(leftBody);

    fixtureDef.userData = R.id.physics_layout_body_right;
    bodyDef.position.set(pixelsToMeters(width) + boxWidth, 0);
    Body rightBody = world.createBody(bodyDef);
    rightBody.createFixture(fixtureDef);
    bounds.add(rightBody);
}
 
开发者ID:Jawnnypoo,项目名称:PhysicsLayout,代码行数:26,代码来源:Physics.java


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