/** Create a chain with isolated end vertices. * @param vertices an array of floats of alternating x, y coordinates. */ public void createChain (float[] vertices) { Vec2[] v = new Vec2[vertices.length / 2]; for (int i = 0, vi = 0; i < vertices.length; i += 2, vi++) { v[vi] = new Vec2(vertices[i], vertices[i + 1]); } shape.createChain(v, v.length); isLooped = false; }
/** Create a chain with isolated end vertices. * @param vertices an array of vertices, these are copied */ public void createChain (Vector2[] vertices) { Vec2[] v = new Vec2[vertices.length]; for (int i = 0; i < vertices.length; i++) { v[i] = new Vec2(vertices[i].x, vertices[i].y); } shape.createChain(v, v.length); isLooped = false; }
/** Create a chain with isolated end vertices. * @param vertices an array of floats of alternating x, y coordinates. * @param offset into the vertices array * @param length after offset (in floats, not float-pairs, so even number) */ public void createChain (float[] vertices, int offset, int length) { final int vertexCount = length / 2; Vec2[] v = new Vec2[vertexCount]; for (int i = offset, vi = 0; vi < vertexCount; i += 2, vi++) { v[vi] = new Vec2(vertices[i], vertices[i + 1]); } shape.createChain(v, vertexCount); isLooped = false; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
ChainShape chain = new ChainShape(); createChain().Vec2[] vertices = new Vec2[2]; vertices[0] = box2d.coordPixelsToWorld(0,150); vertices[1] = box2d.coordPixelsToWorld(width,150); chain.createChain(vertices, vertices.length); FixtureDef fd = new FixtureDef(); fd.shape = chain; fd.density = 1; fd.friction = 0.3; fd.restitution = 0.5; body.createFixture(fd);
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
@Override public Shape clone() { ChainShape clone = new ChainShape(); clone.createChain(m_vertices, m_count); clone.m_prevVertex.set(m_prevVertex); clone.m_nextVertex.set(m_nextVertex); clone.m_hasPrevVertex = m_hasPrevVertex; clone.m_hasNextVertex = m_hasNextVertex; return clone; }
chain.createChain(worldVertices); return chain;
vs[3] = new Vec2(8.0f, 7.0f); ChainShape shape = new ChainShape(); shape.createChain(vs, 4); ground.createFixture(shape, 0.0f);
vs[3] = new Vec2(8.0f, 7.0f); ChainShape shape = new ChainShape(); shape.createChain(vs, 4); ground.createFixture(shape, 0.0f);