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


Java ChainShape.createLoop方法代码示例

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


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

示例1: initScene

import org.jbox2d.collision.shapes.ChainShape; //导入方法依赖的package包/类
public void initScene() {
  
  float dimx = world.transform.box2d_dimx;
  float dimy = world.transform.box2d_dimy;
  float thick = 30f / world.transform.screen_scale;

  float dimxh = dimx/2;
  float dimyh = dimy/2;
  
  float bucket_w = dimx / num_buckets;

  {
    BodyDef bd = new BodyDef();
    Body ground = world.createBody(bd);

    ChainShape shape = new ChainShape();
    Vec2[] vertices = {new Vec2(-dimxh, 0), new Vec2(dimxh, 0), new Vec2(dimxh, dimy), new Vec2(-dimxh, dimy)};
    shape.createLoop(vertices, 4);
    Fixture boundary = ground.createFixture(shape, 0.0f);
    
    PolygonShape pshape = new PolygonShape();
    pshape.setAsBox(dimxh, thick);
    Fixture bottom = ground.createFixture(pshape, 0.0f);

    float shift_x = -dimxh + bucket_w;
    for(int i = 0; i < num_buckets - 1; i++){        
      float w = thick / 6;
      float h = 5f * dimy / 6f;
      pshape.setAsBox(w, h/2, new Vec2(shift_x + i * bucket_w, h/2), 0);
      Fixture separes = ground.createFixture(pshape, 0.0f);
    }

    world.bodies.add(ground, true, color(0), false, color(0), 1f);
    world.setStyle(boundary, false, color(0), false, color(0), 1f);
  }
  

  // save current spawn type
  int spawn_type_cpy = spawn_type;
  
  
  float bucket_w_screen = width / (float) num_buckets;
  for(int i = 0; i < num_buckets; i++){
    float cx = i * bucket_w_screen + bucket_w_screen * 0.5f;
    float cy = 1 * height / 3f;
    
    setParticleSpawnProperties(i);

    float screen_x = cx;
    float screen_y = cy;
    float size_x = bucket_w_screen * 0.66f;
    float size_y = size_x * 2;
    world.mouse_spawn_particles.setBoxShape(size_x, size_y);
    world.mouse_spawn_particles.spawn(screen_x, screen_y);
  }
  
  // reset type/color to last used type
  setParticleSpawnProperties(spawn_type_cpy);
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:60,代码来源:liquidfun_ParticleTypes.java


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