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


Java BodyType.DYNAMIC属性代码示例

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


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

示例1: makeBody

void makeBody(Vec2 center, float w_, float h_) {
    // Define a polygon (this is what we use for a rectangle)
    PolygonShape sd = new PolygonShape();
    float box2dW = box2d.scalarPixelsToWorld(w_ / 2);
    float box2dH = box2d.scalarPixelsToWorld(h_ / 2);
    sd.setAsBox(box2dW, box2dH);

    // Define a fixture
    FixtureDef fd = new FixtureDef();
    fd.shape = sd;
    // Parameters that affect physics
    fd.density = 1;
    fd.friction = 0.3F;
    fd.restitution = 0.5F;

    // Define the body and make it from the shape
    BodyDef bd = new BodyDef();
    bd.type = BodyType.DYNAMIC;
    bd.position.set(box2d.coordPixelsToWorld(center));

    body = box2d.createBody(bd);
    body.createFixture(fd);

    // Give it some initial random velocity
    shake();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:26,代码来源:Box.java

示例2: reportFixture

@Override
public boolean reportFixture(Fixture argFixture) {
  Body body = argFixture.getBody();
  
  // static bodies can be moved too, but need to set to dynamic for the
  // mouse-joint to work.
  BodyType type = body.getType();
  if (BodyType.DYNAMIC == type || enable_static_drag) {
    if (argFixture.testPoint(point)) {
      body_type_cpy = type;
      fixture = argFixture;
      body.setType(BodyType.DYNAMIC);
      return false;
    }
  }
  return true; 
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:17,代码来源:DwMouseDragBodies.java

示例3: Init

@Override
public synchronized void Init()
{
	//System.out.println("init");
	Vector2 meters = Coordinates.PixelsToMeters(this.position);
	Vector2 meterssize = Coordinates.PixelsToMeters(this.size);
	//System.out.println("Metersize: " + meterssize.ToString());
	//System.out.println("Metersize to pixels: " + Coordinates.MetersToPixels(meterssize).ToString());
	//System.out.println("this.size is " + this.size.ToString());
	this.physics = new BoxPhysics(meters.x, meters.y, meterssize.x, meterssize.y, (this.simulatePhysics) ? BodyType.DYNAMIC : BodyType.KINEMATIC, this, this.information);
	this.physics.Create();
	//this.physics.GetPhysicsBody().setFixedRotation(false);
	//this.physics.GetPhysicsBody().setBullet(true);
	super.Init();
	System.out.println("My name is " + this.name);
	//System.out.println("Physics size is " + this.physics.GetPhysicsBody().getToString());
}
 
开发者ID:Joshuagollaher,项目名称:HawkEngine,代码行数:17,代码来源:Box.java

示例4: createCircle

public void createCircle()
{
	float radius = 2.0f;
	CircleShape shape = new CircleShape();
	shape.m_p.setZero();
	shape.m_radius = radius;

	FixtureDef fd = new FixtureDef();
	fd.shape = shape;
	fd.density = 1.0f;
	fd.friction = 0.0f;

	Vec2 p = new Vec2((float)Math.random(), 3.0f + (float)Math.random());
	BodyDef bd = new BodyDef();
	bd.type = BodyType.DYNAMIC;
	bd.position = p;
	//bd.allowSleep = false;
	Body body = m_world.createBody(bd);

	body.createFixture(fd);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:ConfinedTest.java

示例5: step

@Override
public void step(TestbedSettings settings) {

	super.step(settings);

	for (Body b = m_world.getBodyList(); b != null; b = b.getNext())
	{
		if (b.getType() != BodyType.DYNAMIC)
		{
			continue;
		}

		Vec2 p = b.getPosition();
		if (p.x <= -10.0f || 10.0f <= p.x || p.y <= 0.0f || 20.0f <= p.y)
		{
			p.x += 0.0;
		}
	}

	addTextLine("Press 'c' to create a circle");
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:ConfinedTest.java

示例6: makeDomino

public void makeDomino(float x, float y, boolean horizontal, World world) {

    	PolygonShape sd = new PolygonShape();
        sd.setAsBox(.5f*dwidth, .5f*dheight);
        FixtureDef fd = new FixtureDef();
        fd.shape = sd;
        fd.density = ddensity;
        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        fd.friction = dfriction;
        fd.restitution = 0.65f;
        bd.position = new Vec2(x, y);
        bd.angle = horizontal? (float)(Math.PI/2.0):0f;
        Body myBody = world.createBody(bd);
        myBody.createFixture(fd);
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:DominoTower.java

示例7: initTest

@Override
   public void initTest() {
      setTitle("Couple of Things Test");
      
      m_world.setGravity(new Vec2());

      for (int i = 0; i < 2; i++)
      {
//         CircleShape circleShape = new CircleShape();
//         circleShape.m_radius = 1;
//         Shape shape = circleShape;
         PolygonShape polygonShape = new PolygonShape();
         polygonShape.setAsBox(1, 1);
         Shape shape = polygonShape;

         BodyDef bodyDef = new BodyDef();
         bodyDef.type = BodyType.DYNAMIC;
         bodyDef.position.set(5 * i, 0);
         bodyDef.angle = (float) (Math.PI / 4 * i);
         bodyDef.allowSleep = false;
         Body body = m_world.createBody(bodyDef);
         body.createFixture(shape, 5.0f);
         
         body.applyForce(new Vec2(-10000 * (i - 1), 0), new Vec2());
      }
   }
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:MJWTest.java

示例8: 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

示例9: init

@Override
public void init(RunConfig config) throws InvalidTestFormatException {
	super.init(config);
	gravity = new Vec2(0.0f, -10.0f);
	platformFixtureDef = new FixtureDef();
	PolygonShape platformPolygonShape = new PolygonShape();
	platformPolygonShape.setAsBox(15.0f, 0.1f);
	platformFixtureDef.shape = platformPolygonShape;

	dominoFixtureDef = new FixtureDef();
	PolygonShape dominoPolygonShape = new PolygonShape();
	dominoPolygonShape.setAsBox(0.2f, 2.5f);
	dominoFixtureDef.shape = dominoPolygonShape;
	dominoFixtureDef.density = 25.0f;
	dominoFixtureDef.friction = .5f;
	dominoBody = new BodyDef();
	dominoBody.type = BodyType.DYNAMIC;
	
	floorFixtureDef = new FixtureDef();
	PolygonShape floorPolygonShape = new PolygonShape();
	floorPolygonShape.setAsBox(60.0f, 5.0f);
	floorFixtureDef.shape = floorPolygonShape;
	floor = new BodyDef();
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:24,代码来源:DominoBullet.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.DYNAMIC;
  bodyDef.position = new Vec2(0, 0);
  Body body = world.createBody(bodyDef);

  CircleShape circleShape = new CircleShape();
  circleShape.m_radius = getRadius();
  fixtureDef.shape = circleShape;
  fixtureDef.density = 0.4f;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 0.35f;
  circleShape.m_p.set(0, 0);
  body.createFixture(fixtureDef);
  body.setLinearDamping(0.2f);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:20,代码来源:Pea.java

示例11: initPhysicsBody

Body initPhysicsBody(World world, float x, float y, float angle) {
  FixtureDef fixtureDef = new FixtureDef();
  BodyDef bodyDef = new BodyDef();
  bodyDef.type = BodyType.DYNAMIC;
  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, polygon[0].y + getSpringBoxHeight());
  polygon[3] = new Vec2(-getWidth() / 2f, polygon[1].y + getSpringBoxHeight());
  polygonShape.set(polygon, polygon.length);
  fixtureDef.shape = polygonShape;
  fixtureDef.friction = 0.1f;
  fixtureDef.restitution = 1.4f;
  body.createFixture(fixtureDef);
  body.setTransform(new Vec2(x, y), angle);
  return body;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:21,代码来源:BlockSpring.java

示例12: 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

示例13: step

@Override
public synchronized void step(TestbedSettings settings) {
  super.step(settings);

  if (m_count < MAX_NUM) {
    BodyDef bd = new BodyDef();
    bd.type = BodyType.DYNAMIC;
    bd.position.set(0.0f, 10.0f);
    Body body = m_world.createBody(bd);

    PolygonShape shape = new PolygonShape();
    shape.setAsBox(0.125f, 0.125f);
    body.createFixture(shape, 1.0f);

    ++m_count;
  }
}
 
开发者ID:weimingtom,项目名称:jbox2d,代码行数:17,代码来源:Tumbler.java

示例14: step

@Override
public void step(TestbedSettings settings) {

	super.step(settings);

	for (Body b = getWorld().getBodyList(); b != null; b = b.getNext())
	{
		if (b.getType() != BodyType.DYNAMIC)
		{
			continue;
		}

		Vec2 p = b.getPosition();
		if (p.x <= -10.0f || 10.0f <= p.x || p.y <= 0.0f || 20.0f <= p.y)
		{
			p.x += 0.0;
		}
	}

	addTextLine("Press 'c' to create a circle");
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:21,代码来源:ConfinedTest.java

示例15: makeDomino

public void makeDomino(float x, float y, boolean horizontal, World world) {

    PolygonShape sd = new PolygonShape();
    sd.setAsBox(.5f * dwidth, .5f * dheight);
    FixtureDef fd = new FixtureDef();
    fd.shape = sd;
    fd.density = ddensity;
    BodyDef bd = new BodyDef();
    bd.type = BodyType.DYNAMIC;
    fd.friction = dfriction;
    fd.restitution = 0.65f;
    bd.position = new Vec2(x, y);
    bd.angle = horizontal ? (float) (Math.PI / 2.0) : 0f;
    Body myBody = getWorld().createBody(bd);
    myBody.createFixture(fd);
  }
 
开发者ID:weimingtom,项目名称:jbox2d,代码行数:16,代码来源:DominoTower.java


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