本文整理汇总了Java中com.badlogic.gdx.physics.box2d.BodyDef.BodyType方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDef.BodyType方法的具体用法?Java BodyDef.BodyType怎么用?Java BodyDef.BodyType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.BodyDef
的用法示例。
在下文中一共展示了BodyDef.BodyType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEntityBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
/**
* Erlaubt es den Unterklassen möglichst einfach einen beliebigen Box2D Körper zu erstellen.
*
* @param position die Startposition des Body
* @param shape die Form, die für dne Body verwendet werden soll
* @param type der Typ des Körpers
* @return ein Box2D Körper
*/
protected Body createEntityBody(Vector2 position, Shape shape, BodyDef.BodyType type)
{
position.scl(Physics.MPP);
BodyDef bodyDef = new BodyDef();
bodyDef.type = type;
bodyDef.position.set(position);
bodyDef.fixedRotation = true;
Body body = worldObjectManager.getPhysicalWorld().createBody(bodyDef);
body.setUserData(this);
FixtureDef fixture = new FixtureDef();
fixture.shape = shape;
fixture.filter.categoryBits = Physics.CATEGORY_ENTITIES;
fixture.filter.maskBits = Physics.MASK_ENTITIES;
body.createFixture(fixture).setUserData(this);
shape.dispose();
return body;
}
示例2: createGameObjectWithBox2DBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public static GameObject createGameObjectWithBox2DBody(Vector2 gameObjectPos, Texture texture, Vector3 densityFrictionRestitution,
BodyDef.BodyType bodyType, Shape.Type shapeType,
World world) {
GameObject gameObject = new GameObject();
gameObject.setPosition(gameObjectPos.x, gameObjectPos.y);
gameObject.setTexture(texture);
gameObject.setSprite(new Sprite(texture));
gameObject.getSprite().setOriginCenter();
gameObject.setWorld(world);
BodyCreator bodyCreator = new BodyCreator();
gameObject.setBody(bodyCreator.createBody(new Vector2(gameObject.getX(), gameObject.getY()), texture, bodyType, world, shapeType, densityFrictionRestitution));
bodyCreator = null;
return gameObject;
}
示例3: createBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public Body createBody(Vector2 position, Texture texture, BodyDef.BodyType bodyType, World world, Shape.Type shape, Vector3 densityRestitutionFriction) {
this.texture = texture;
bodyDef = createBodyDef(bodyType, position);
body = world.createBody(bodyDef);
FixtureCreator.createFixture(body, createShape(shape), densityRestitutionFriction);
return body;
}
示例4: boxBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public static Body boxBody(World world,BodyDef.BodyType type, Vector2 position, Vector2 dimensions, float thickness,float density, float friction, float restitution,boolean isSensor){
Body b = world.createBody(bodyDef(type,position));
PolygonShape s = new PolygonShape();
FixtureDef fd = fixtureDef(density,friction,restitution,s,isSensor);
//top
s.setAsBox(dimensions.x, thickness, new Vector2(position.x,position.y + dimensions.y), 0);
fd.shape = s;
b.createFixture(fd);
//Bottom
s.setAsBox(dimensions.x, thickness, new Vector2(position.x,position.y - dimensions.y), 0);
fd.shape = s;
b.createFixture(fd);
//Left
s.setAsBox(thickness, dimensions.y, new Vector2(position.x - dimensions.x,position.y), 0);
fd.shape = s;
b.createFixture(fd);
//Right
s.setAsBox(thickness, dimensions.y, new Vector2(position.x + dimensions.x,position.y), 0);
fd.shape = s;
b.createFixture(fd);
s.dispose();
return b;
}
示例5: createBodyDef
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
private BodyDef createBodyDef(BodyDef.BodyType bodyType, Vector2 position) {
BodyDef bodyDef_ = new BodyDef();
bodyDef_.type = bodyType;
bodyDef_.position.set(position);
return bodyDef_;
}
示例6: getBodyType
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public BodyDef.BodyType getBodyType() {
return bodyDef.type;
}
示例7: getBodyType
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
@Override
protected BodyDef.BodyType getBodyType() {
return BodyDef.BodyType.DynamicBody;
}
示例8: getBodyType
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
protected BodyDef.BodyType getBodyType() {
return BodyDef.BodyType.StaticBody;
}
示例9: getBodyType
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
@Override
protected BodyDef.BodyType getBodyType() {
return BodyDef.BodyType.KinematicBody;
}
示例10: bodyDef
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public static BodyDef bodyDef(BodyDef.BodyType type, Vector2 position){
BodyDef bd = new BodyDef();
bd.type = type;
bd.position.set(position);
return bd;
}
示例11: circleBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public static Body circleBody(World world, BodyDef.BodyType type, Vector2 position, float radius, float density,float friction,float restitution,boolean isSensor){
Body b = world.createBody(bodyDef(type,position));
circleFixture(b,radius,density,friction,restitution,isSensor);
return b;
}
示例12: rectangleBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public static Body rectangleBody(World world,BodyDef.BodyType type, Vector2 position, Vector2 dimensions, float density,float friction, float restitution,boolean isSensor){
Body b = world.createBody(bodyDef(type,position));
rectangleFixture(b,dimensions,density,friction,restitution,isSensor);
return b;
}
示例13: triangleBody
import com.badlogic.gdx.physics.box2d.BodyDef; //导入方法依赖的package包/类
public static Body triangleBody(World world,BodyDef.BodyType type, Vector2 position, Vector2 dimensions, float density,float friction, float restitution,boolean isSensor){
Body b = world.createBody(bodyDef(type,position));
triangleFixture(b,dimensions,density,friction,restitution,isSensor);
return b;
}