本文整理汇总了Java中com.badlogic.gdx.physics.box2d.EdgeShape.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java EdgeShape.dispose方法的具体用法?Java EdgeShape.dispose怎么用?Java EdgeShape.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.EdgeShape
的用法示例。
在下文中一共展示了EdgeShape.dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WorldEdge
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
public WorldEdge(World world, WorldEdgeType type){
BodyDef edgeBody = new BodyDef();
edgeBody.type = BodyDef.BodyType.StaticBody;
if (type.equals(WorldEdgeType.Right)){
edgeBody.position.set(GameMain.WIDTH / GameMain.PIXELS_TO_METERS, 0);
}else{
edgeBody.position.set(0, 0);
}
FixtureDef edgeDef = new FixtureDef();
edgeDef.filter.categoryBits = GameMain.WORLD_ENTITY;
edgeDef.filter.maskBits = GameMain.METEOR_ENTITY;
EdgeShape edge = new EdgeShape();
edge.set(0, 0, 0, GameMain.HEIGHT);
edgeDef.shape = edge;
body = world.createBody(edgeBody);
body.createFixture(edgeDef);
edge.dispose();
}
示例2: createBody
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
/**
* Creates the body.
*/
@Override
public void createBody()
{
bodyDef.position.x = x / B2FlxB.RATIO;
bodyDef.position.y = y / B2FlxB.RATIO;
position = bodyDef.position;
body = B2FlxB.world.createBody(bodyDef);
EdgeShape s;
for(int i = 0; i < shapes.length; i++)
{
s = shapes[i];
fixtureDef.shape = s;
body.createFixture(fixtureDef);
s.dispose();
s = null;
}
shape = null;
}
示例3: addEdge
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
private static void addEdge(Body body, float startX, float startY, float endX, float endY) {
EdgeShape shape = new EdgeShape();
shape.set(startX, startY, endX, endY);
FixtureDef fixture = new FixtureDef();
fixture.shape = shape;
fixture.density = 1f;
body.createFixture(fixture).setUserData(new FixtureUserData(UserDataType.LOS_BLOCKER_TILE));
shape.dispose();
}
示例4: createEdge
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
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;
}
示例5: createPolygonBody
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
/**
* Genera un pol�gono
* @param world El mundo
* @param x Posici�n x
* @param y Posici�n y
* @return El cuerpo creado
*/
public static Body createPolygonBody(World world, float x, float y, float width, float height) {
// Define un cuerpo f�sico din�mico con posici�n en el mundo 2D
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
//bodyDef.position.set(x, y);
Body body = world.createBody(bodyDef);
// Define una forma circular de 6 unidades de di�metro
EdgeShape polygon = new EdgeShape();
polygon.set(new Vector2(x, y), new Vector2(x + width, y + height));
// Define un elemento f�sico y sus propiedades y le asigna la forma circular
FixtureDef fixtureDef = new FixtureDef();
// Forma del elemento f�sico
fixtureDef.shape = polygon;
// Densidad (kg/m^2)
fixtureDef.density = 1f;
// Coeficiente de fricci�n (0 - 1)
fixtureDef.friction = 0.1f;
// Elasticidad (0 - 1)
fixtureDef.restitution = 0.2f;
// A�ade el elemento f�sico al cuerpo del mundo 2D
Fixture fixture = body.createFixture(fixtureDef);
polygon.dispose();
return body;
}
示例6: createPolygonBody
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
/**
* Genera un pol�gono
* @param world El mundo
* @param x Posici�n x
* @param y Posici�n y
* @return El cuerpo creado
*/
public static Body createPolygonBody(World world, float x, float y, float width, float height) {
// Define un cuerpo f�sico din�mico con posici�n en el mundo 2D
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
//bodyDef.position.set(x, y);
Body body = world.createBody(bodyDef);
// Define una forma circular de 6 unidades de di�metro
EdgeShape polygon = new EdgeShape();
polygon.set(new Vector2(x, y), new Vector2(x + width, y + height));
// Define un elemento f�sico y sus propiedades y le asigna la forma circular
FixtureDef fixtureDef = new FixtureDef();
// Forma del elemento f�sico
fixtureDef.shape = polygon;
// Densidad (kg/m^2)
fixtureDef.density = 1f;
// Coeficiente de fricci�n (0 - 1)
fixtureDef.friction = 1f;
// Elasticidad (0 - 1)
fixtureDef.restitution = 0.2f;
// A�ade el elemento f�sico al cuerpo del mundo 2D
Fixture fixture = body.createFixture(fixtureDef);
polygon.dispose();
return body;
}
示例7: create
import com.badlogic.gdx.physics.box2d.EdgeShape; //导入方法依赖的package包/类
@Override
public void create () {
batch = new SpriteBatch();
Box2D.init();
mundo = new World(new Vector2(0, -9.8f), true);
debugRenderer = new Box2DDebugRenderer();
//crear la camara del mundo box2d
camaramundo = new OrthographicCamera();
camaramundo.setToOrtho(false, SCREEN_WIDTH/units, SCREEN_HEIGHT/units);
//OBJETO PISO
BodyDef cuerpoPiso = new BodyDef();
cuerpoPiso.type = BodyType.StaticBody;
//creamos una l�nea que representa el suelo, del ancho de la pantalla
EdgeShape linea = new EdgeShape();
linea.set(0, 20/units, SCREEN_WIDTH/units, 20/units);
//creamos el fixture
FixtureDef fixDef=new FixtureDef();
fixDef.shape=linea;
fixDef.filter.categoryBits = BIT_PISO;
fixDef.filter.maskBits = BIT_PELOTA | BIT_CAJA;
//lo a�adimos al mundo
piso = mundo.createBody(cuerpoPiso);
piso.createFixture(fixDef).setUserData("piso"); // a�adimos el fixture al objeto
//PAREDES
cuerpoPiso.type = BodyType.StaticBody;
//creamos una l�nea que representa la pared izquierda, del alto de la pantalla
linea.set(0, 0, 0 , SCREEN_HEIGHT*2/units);
//creamos el fixture
fixDef.shape=linea;
fixDef.filter.categoryBits = BIT_PISO;
fixDef.filter.maskBits = BIT_PELOTA | BIT_CAJA;
//lo a�adimos al mundo
piso = mundo.createBody(cuerpoPiso);
piso.createFixture(fixDef).setUserData("pared"); // a�adimos el fixture al objeto
cuerpoPiso.type = BodyType.StaticBody;
//creamos una l�nea que representa la pared derecha, del alto de la pantalla
linea.set(SCREEN_WIDTH/units, 0, SCREEN_WIDTH/units , SCREEN_HEIGHT*2/units);
//creamos el fixture
fixDef.shape=linea;
fixDef.filter.categoryBits = BIT_PISO;
fixDef.filter.maskBits = BIT_PELOTA | BIT_CAJA;
//lo a�adimos al mundo
piso = mundo.createBody(cuerpoPiso);
piso.createFixture(fixDef).setUserData("pared"); // a�adimos el fixture al objeto
//OBJETO CAJA GIRATORIA
BodyDef cuerpoCaja = new BodyDef();
cuerpoCaja.type = BodyType.KinematicBody;
cuerpoCaja.position.set(SCREEN_WIDTH/2/units, SCREEN_HEIGHT/4/units);
//creamos un rect�ngulo que representa la caja giratoria
PolygonShape rectangulo = new PolygonShape();
rectangulo.setAsBox(100/units, 10/units);
//creamos el fixture
fixDef.shape=rectangulo;
fixDef.filter.categoryBits = BIT_CAJA;
fixDef.filter.maskBits = BIT_PELOTA;
//lo a�adimos al mundo
caja = mundo.createBody(cuerpoCaja);
caja.createFixture(fixDef).setUserData("caja"); // a�adimos el fixture al objeto
//es importante hacer dispose de los shapes despues de usarlos
rectangulo.dispose();
linea.dispose();
}