congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
EdgeShape
Code IndexAdd Tabnine to your IDE (free)

How to use
EdgeShape
in
com.badlogic.gdx.physics.box2d

Best Java code snippets using com.badlogic.gdx.physics.box2d.EdgeShape (Showing top 20 results out of 315)

origin: libgdx/libgdx

private Body createEdge (BodyType type, float x1, float y1, float x2, float y2, float density) {
  BodyDef def = new BodyDef();
  def.type = type;
  Body box = world.createBody(def);
  EdgeShape poly = new EdgeShape();
  poly.set(new Vector2(0, 0), new Vector2(x2 - x1, y2 - y1));
  box.createFixture(poly, density);
  box.setTransform(x1, y1, 0);
  poly.dispose();
  return box;
}
origin: libgdx/libgdx

public void getVertex0 (Vector2 vec) {
  jniGetVertex0(addr, vertex);
  vec.x = vertex[0];
  vec.y = vertex[1];
}
origin: libgdx/libgdx

groundBody = world.createBody(bodyDef);
EdgeShape shape = new EdgeShape();
shape.set(new Vector2(-20.0f, 0.0f), new Vector2(20.0f, 0.0f));
groundBody.createFixture(shape, 0.0f);
origin: libgdx/libgdx

EdgeShape shape = new EdgeShape();
shape.set(new Vector2(-20, 0), new Vector2(20, 0));
ground.createFixture(shape, 0);
shape.dispose();
EdgeShape shape = new EdgeShape();
shape.setRadius(0);
shape.set(new Vector2(-8, 1), new Vector2(-6, 1));
ground.createFixture(shape, 0);
shape.set(new Vector2(-6, 1), new Vector2(-4, 1));
ground.createFixture(shape, 0);
shape.set(new Vector2(-4, 1), new Vector2(-2, 1));
ground.createFixture(shape, 0);
shape.dispose();
EdgeShape shape = new EdgeShape();
float d = 2 * 2 * 0.005f;
shape.setRadius(0);
shape.set(new Vector2(-1 + d, 3), new Vector2(1 - d, 3));
ground.createFixture(shape, 0);
shape.set(new Vector2(1, 3 + d), new Vector2(1, 5 - d));
ground.createFixture(shape, 0);
shape.set(new Vector2(1 - d, 5), new Vector2(-1 + d, 5));
ground.createFixture(shape, 0);
shape.set(new Vector2(-1, 5 - d), new Vector2(-1, 3 + d));
ground.createFixture(shape, 0);
shape.dispose();
origin: libgdx/libgdx

/** Returns the shape of this fixture */
public Shape getShape () {
  if (shape == null) {
    org.jbox2d.collision.shapes.Shape shape2 = fixture.getShape();
    ShapeType type = shape2.getType();
    if (type == ShapeType.CHAIN) shape = new ChainShape((org.jbox2d.collision.shapes.ChainShape)shape2);
    if (type == ShapeType.CIRCLE) shape = new CircleShape((org.jbox2d.collision.shapes.CircleShape)shape2);
    if (type == ShapeType.EDGE) shape = new EdgeShape((org.jbox2d.collision.shapes.EdgeShape)shape2);
    if (type == ShapeType.POLYGON) shape = new PolygonShape((org.jbox2d.collision.shapes.PolygonShape)shape2);
  }
  return shape;
}
origin: libgdx/libgdx

/** Set this as an isolated edge. */
public void set (Vector2 v1, Vector2 v2) {
  set(v1.x, v1.y, v2.x, v2.y);
}
origin: libgdx/libgdx

edge.getVertex1(vertices[0]);
edge.getVertex2(vertices[1]);
transform.mul(vertices[0]);
transform.mul(vertices[1]);
origin: BrentAureli/SuperMario

public void defineMario(){
  BodyDef bdef = new BodyDef();
  bdef.position.set(32 / MarioBros.PPM, 32 / 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.BRICK_BIT |
      MarioBros.ENEMY_BIT |
      MarioBros.OBJECT_BIT |
      MarioBros.ENEMY_HEAD_BIT |
      MarioBros.ITEM_BIT;
  fdef.shape = shape;
  b2body.createFixture(fdef).setUserData(this);
  EdgeShape head = new EdgeShape();
  head.set(new Vector2(-2 / MarioBros.PPM, 6 / MarioBros.PPM), new Vector2(2 / MarioBros.PPM, 6 / MarioBros.PPM));
  fdef.filter.categoryBits = MarioBros.MARIO_HEAD_BIT;
  fdef.shape = head;
  fdef.isSensor = true;
  b2body.createFixture(fdef).setUserData(this);
}
origin: libgdx/libgdx

EdgeShape shape = new EdgeShape();
shape.set(new Vector2(-20, 0), new Vector2(20, 0));
ground.createFixture(shape, 0);
shape.dispose();
EdgeShape shape = new EdgeShape();
shape.setRadius(0);
shape.set(new Vector2(-8, 1), new Vector2(-6, 1));
ground.createFixture(shape, 0);
shape.set(new Vector2(-6, 1), new Vector2(-4, 1));
ground.createFixture(shape, 0);
shape.set(new Vector2(-4, 1), new Vector2(-2, 1));
ground.createFixture(shape, 0);
shape.dispose();
EdgeShape shape = new EdgeShape();
float d = 2 * 2 * 0.005f;
shape.setRadius(0);
shape.set(new Vector2(-1 + d, 3), new Vector2(1 - d, 3));
ground.createFixture(shape, 0);
shape.set(new Vector2(1, 3 + d), new Vector2(1, 5 - d));
ground.createFixture(shape, 0);
shape.set(new Vector2(1 - d, 5), new Vector2(-1 + d, 5));
ground.createFixture(shape, 0);
shape.set(new Vector2(-1, 5 - d), new Vector2(-1, 3 + d));
ground.createFixture(shape, 0);
shape.dispose();
origin: libgdx/libgdx

/** Returns the shape of this fixture */
public Shape getShape () {
  if (shape == null) {
    long shapeAddr = jniGetShape(addr);
    if (shapeAddr == 0) throw new GdxRuntimeException("Null shape address!");
    int type = Shape.jniGetType(shapeAddr);
    switch (type) {
    case 0:
      shape = new CircleShape(shapeAddr);
      break;
    case 1:
      shape = new EdgeShape(shapeAddr);
      break;
    case 2:
      shape = new PolygonShape(shapeAddr);
      break;
    case 3:
      shape = new ChainShape(shapeAddr);
      break;
    default:
      throw new GdxRuntimeException("Unknown shape type!");
    }
  }
  return shape;
}
origin: libgdx/libgdx

/** Set this as an isolated edge. */
public void set (Vector2 v1, Vector2 v2) {
  set(v1.x, v1.y, v2.x, v2.y);
}
origin: libgdx/libgdx

edge.getVertex1(vertices[0]);
edge.getVertex2(vertices[1]);
transform.mul(vertices[0]);
transform.mul(vertices[1]);
origin: libgdx/libgdx

@Override
protected void createWorld (World world) {
  {
    BodyDef bd = new BodyDef();
    Body ground = world.createBody(bd);
    EdgeShape shape = new EdgeShape();
    shape.set(new Vector2(-40, 0), new Vector2(40, 0));
    ground.createFixture(shape, 0);
    shape.dispose();
  }
  {
    CircleShape shape = new CircleShape();
    shape.setRadius(1.0f);
    for (int i = 0; i < e_count; i++) {
      BodyDef bd = new BodyDef();
      bd.type = BodyType.DynamicBody;
      bd.position.set(0, 4.0f + 3.0f * i);
      Body body = world.createBody(bd);
      body.createFixture(shape, 1.0f);
    }
    shape.dispose();
  }
}
origin: BrentAureli/SuperMario

public void redefineMario(){
  Vector2 position = b2body.getPosition();
  world.destroyBody(b2body);
  BodyDef bdef = new BodyDef();
  bdef.position.set(position);
  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.BRICK_BIT |
      MarioBros.ENEMY_BIT |
      MarioBros.OBJECT_BIT |
      MarioBros.ENEMY_HEAD_BIT |
      MarioBros.ITEM_BIT;
  fdef.shape = shape;
  b2body.createFixture(fdef).setUserData(this);
  EdgeShape head = new EdgeShape();
  head.set(new Vector2(-2 / MarioBros.PPM, 6 / MarioBros.PPM), new Vector2(2 / MarioBros.PPM, 6 / MarioBros.PPM));
  fdef.filter.categoryBits = MarioBros.MARIO_HEAD_BIT;
  fdef.shape = head;
  fdef.isSensor = true;
  b2body.createFixture(fdef).setUserData(this);
  timeToRedefineMario = false;
}
origin: com.badlogicgames.gdx/gdx-box2d

/** Returns the shape of this fixture */
public Shape getShape () {
  if (shape == null) {
    long shapeAddr = jniGetShape(addr);
    if (shapeAddr == 0) throw new GdxRuntimeException("Null shape address!");
    int type = Shape.jniGetType(shapeAddr);
    switch (type) {
    case 0:
      shape = new CircleShape(shapeAddr);
      break;
    case 1:
      shape = new EdgeShape(shapeAddr);
      break;
    case 2:
      shape = new PolygonShape(shapeAddr);
      break;
    case 3:
      shape = new ChainShape(shapeAddr);
      break;
    default:
      throw new GdxRuntimeException("Unknown shape type!");
    }
  }
  return shape;
}
origin: com.badlogicgames.gdx/gdx-box2d

/** Set this as an isolated edge. */
public void set (Vector2 v1, Vector2 v2) {
  set(v1.x, v1.y, v2.x, v2.y);
}
origin: com.badlogicgames.gdx/gdx-box2d

edge.getVertex1(vertices[0]);
edge.getVertex2(vertices[1]);
transform.mul(vertices[0]);
transform.mul(vertices[1]);
origin: com.badlogicgames.gdx/gdx-box2d

public void getVertex0 (Vector2 vec) {
  jniGetVertex0(addr, vertex);
  vec.x = vertex[0];
  vec.y = vertex[1];
}
origin: libgdx/libgdx

Body ground = world.createBody(bd);
EdgeShape shape = new EdgeShape();
shape.set(new Vector2(-40, 0), new Vector2(40, 0));
ground.createFixture(shape, 0.0f);
shape.dispose();
origin: BrentAureli/SuperMario

public 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.BRICK_BIT |
      MarioBros.ENEMY_BIT |
      MarioBros.OBJECT_BIT |
      MarioBros.ENEMY_HEAD_BIT |
      MarioBros.ITEM_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, 6 / MarioBros.PPM), new Vector2(2 / MarioBros.PPM, 6 / MarioBros.PPM));
  fdef.filter.categoryBits = MarioBros.MARIO_HEAD_BIT;
  fdef.shape = head;
  fdef.isSensor = true;
  b2body.createFixture(fdef).setUserData(this);
  timeToDefineBigMario = false;
}
com.badlogic.gdx.physics.box2dEdgeShape

Javadoc

A line segment (edge) shape. These can be connected in chains or loops to other edge shapes. The connectivity information is used to ensure correct contact normals.

Most used methods

  • <init>
  • set
    Set this as an isolated edge.
  • dispose
  • getVertex1
  • getVertex2
  • jniGetVertex0
  • jniGetVertex1
  • jniGetVertex2
  • jniGetVertex3
  • jniHasVertex0
  • jniHasVertex3
  • jniSet
  • jniHasVertex3,
  • jniSet,
  • jniSetHasVertex0,
  • jniSetHasVertex3,
  • jniSetVertex0,
  • jniSetVertex3,
  • newEdgeShape,
  • setRadius

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now