本文整理汇总了Java中org.jbox2d.dynamics.FixtureDef.setFriction方法的典型用法代码示例。如果您正苦于以下问题:Java FixtureDef.setFriction方法的具体用法?Java FixtureDef.setFriction怎么用?Java FixtureDef.setFriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbox2d.dynamics.FixtureDef
的用法示例。
在下文中一共展示了FixtureDef.setFriction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Create
import org.jbox2d.dynamics.FixtureDef; //导入方法依赖的package包/类
@Override
public void Create()
{
BodyDef def = new BodyDef();
def.position.set(new Vec2(x, y));
def.type = type;
def.angle = 0;
this.body = Game.world.createBody(def);
PolygonShape shape = new PolygonShape();
shape.setAsBox(w/2, h/2);
FixtureDef fixture = new FixtureDef();
Filter filter = new Filter();
filter.groupIndex = 1;
fixture.density = 0.1f;
fixture.setShape(shape);
fixture.setFilter(filter);
fixture.isSensor = false;
fixture.setFriction(0.5f);
fixture.friction = 1;
fixture.setUserData(this.sprite);
Physics.SetPhysicsAccordingly(this.body, fixture, information);
body.createFixture(fixture);
}
示例2: GroundPhysics
import org.jbox2d.dynamics.FixtureDef; //导入方法依赖的package包/类
public GroundPhysics(float x, float y, float w, float h, BodyType type, Ground ground)
{
super(new PhysicsInformation(0, 0, false));
BodyDef def = new BodyDef();
def.position.set(new Vec2(x, y));
def.type = type;
def.angle = 0;
this.body = Game.world.createBody(def);
PolygonShape shape = new PolygonShape();
shape.setAsBox(w/2, h/2);
FixtureDef fixture = new FixtureDef();
Filter filter = new Filter();
filter.groupIndex = 1;
fixture.density = 0.1f;
fixture.setShape(shape);
fixture.setFilter(filter);
fixture.isSensor = false;
fixture.setFriction(0.5f);
fixture.restitution = 0;
fixture.density = 1;
fixture.friction = 1;
fixture.setUserData(ground);
body.createFixture(fixture);
}
示例3: Create
import org.jbox2d.dynamics.FixtureDef; //导入方法依赖的package包/类
@Override
public void Create()
{
BodyDef def = new BodyDef();
def.position.set(new Vec2(x, y));
def.type = type;
def.angle = 0;
this.body = Game.world.createBody(def);
PolygonShape shape = new PolygonShape();
shape.setAsBox(w/2, h/2);
FixtureDef fixture = new FixtureDef();
Filter filter = new Filter();
filter.groupIndex = 1;
fixture.density = 0.1f;
fixture.setShape(shape);
fixture.setFilter(filter);
fixture.isSensor = false;
fixture.setFriction(0.5f);
fixture.friction = 1;
fixture.setUserData(box);
//Physics.SetPhysicsAccordingly(this.body, fixture, information);
body.createFixture(fixture);
}
示例4: addObjectToPhysicsWorld
import org.jbox2d.dynamics.FixtureDef; //导入方法依赖的package包/类
private static Body addObjectToPhysicsWorld(int objectWidth,int objectHeight,Vec2 loc, String label, float density, float friction, float restitution){
Body body;
//Body def
BodyDef bd = new BodyDef();
bd.type = BodyType.DYNAMIC;
bd.position.set(Public.box2d.coordPixelsToWorld(loc.x,loc.y));
if(!label.equals("")){
bd.setUserData("PhysicalGameObject,"+label);
}else{
bd.setUserData("PhysicalGameObject");
}
//Create body
body = Public.box2d.createBody(bd);
//Create Shape
PolygonShape ps = new PolygonShape();
ps.setAsBox(Public.box2d.scalarPixelsToWorld(objectWidth/2),Public.box2d.scalarPixelsToWorld(objectHeight/2));
//Fixture
FixtureDef fd = new FixtureDef();
fd.shape = ps;
fd.setDensity(density);
fd.setFriction(friction);
fd.setRestitution(restitution);
body.createFixture(fd);
return body;
}
示例5: buildShape
import org.jbox2d.dynamics.FixtureDef; //导入方法依赖的package包/类
@Override
protected void buildShape()
{
if (m_Data == null)
return;
List<Float> lineVisualizerVertexes = null;
if (getDrawDebugLines() && m_LineVisualizer == null)
{
m_LineVisualizer = (LineVisualizer)getGameObject().get().addComponent(LineVisualizer.class);
m_LineVisualizer.setDrawPrimitiveMode(LinePrimitive.Lines);
lineVisualizerVertexes = new ArrayList<>();
}
List<FixtureDef> fixtureDefinitions = new ArrayList<>();
for(int y=0;y<m_DataHeight;y++)
for(int x=0;x<m_DataWidth;x++)
{
int dataIndex = (y*m_DataWidth)+x;
GridColliderDefinition currentColDef = m_GridColliderDefinitions[m_Data[dataIndex]];
for(int i=0;i<currentColDef.edgeDefinitions.length;i++)
{
EdgeDefinition currentEdgeDef = currentColDef.edgeDefinitions[i];
FixtureDef currentFixtureDef = new FixtureDef();
currentFixtureDef.shape = new EdgeShape();
currentFixtureDef.setDensity (currentEdgeDef.density);
currentFixtureDef.setFriction (currentEdgeDef.friction);
currentFixtureDef.setRestitution(currentEdgeDef.restitution);
currentFixtureDef.setSensor(ColliderType.Collidable.toB2TriggerBool());
buildAFixture(x,y,m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes,null,currentFixtureDef);
fixtureDefinitions.add(currentFixtureDef);
if (getDrawDebugLines())
for(int j=0;j<m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes.length;j++)
{
lineVisualizerVertexes.add(m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes[j].x+x-0.3f);
lineVisualizerVertexes.add(0.1f);
lineVisualizerVertexes.add(m_GridColliderDefinitions[m_Data[dataIndex]].edgeDefinitions[i].vertexes[j].y+y-m_DataHeight+0.5f);
}
}
}
//Convert to array
m_FixtureDefinitions = fixtureDefinitions.toArray(new FixtureDef[fixtureDefinitions.size()]);
//update linevisualizer//lineVisualizerVertexes.toArray(new float[lineVisualizerVertexes.size()]
if (getDrawDebugLines())
{
float[] visdata = new float[lineVisualizerVertexes.size()];
for(int i=0;i<lineVisualizerVertexes.size();i++)
visdata[i] = lineVisualizerVertexes.get(i);
m_LineVisualizer.setVertexData(visdata);
}
}