本文整理汇总了Java中com.badlogic.gdx.physics.box2d.PolygonShape.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java PolygonShape.dispose方法的具体用法?Java PolygonShape.dispose怎么用?Java PolygonShape.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.PolygonShape
的用法示例。
在下文中一共展示了PolygonShape.dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBody
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
private void createBody() {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
// Set our body's starting position in the world
bodyDef.position.set(Gdx.input.getX() / 100f, camera.viewportHeight - Gdx.input.getY() / 100f);
// Create our body in the world using our body definition
Body body = world.createBody(bodyDef);
// Create a circle shape and set its radius to 6
PolygonShape square = new PolygonShape();
square.setAsBox(0.3f, 0.3f);
// Create a fixture definition to apply our shape to
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = square;
fixtureDef.density = 0.5f;
fixtureDef.friction = 0.5f;
fixtureDef.restitution = 0.5f;
// Create our fixture and attach it to the body
body.createFixture(fixtureDef);
square.dispose();
}
示例2: createTopTube
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public static Array<Body> createTopTube(World world, float posX) {
float posY = generateTubePosition();
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.KinematicBody;
bodyDef.position.set(posX, posY);
PolygonShape shape = new PolygonShape();
shape.setAsBox(Constants.TUBE_WIDTH / 2, Constants.TUBE_HEIGHT / 2);
Body bodyTop = world.createBody(bodyDef);
bodyTop.createFixture(shape, 0f);
bodyTop.resetMassData();
shape.dispose();
bodyTop.setLinearVelocity(Constants.TUBE_SPEED, 0.0f);
Array<Body> bodies = new Array<Body>();
bodies.add(bodyTop);
bodies.add(createBottomTube(world, posX, posY));
return bodies;
}
示例3: createBody
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
@Override
protected Body createBody(final Box2DService box2d) {
final BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.fixedRotation = true;
final PolygonShape shape = new PolygonShape();
shape.setAsBox(Block.HALF_SIZE, Block.HALF_SIZE);
final FixtureDef fixtureDef = new FixtureDef();
fixtureDef.isSensor = true;
fixtureDef.shape = shape;
fixtureDef.filter.categoryBits = Box2DUtil.CAT_BLOCK;
fixtureDef.filter.maskBits = Box2DUtil.MASK_BLOCK;
final Body body = box2d.getWorld().createBody(bodyDef);
body.createFixture(fixtureDef);
shape.dispose();
return body;
}
示例4: createBody
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
@Override
protected Body createBody(final Box2DService box2d) {
final BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.fixedRotation = true;
final PolygonShape shape = new PolygonShape();
shape.setAsBox(HALF_SIZE, HALF_SIZE);
final FixtureDef fixtureDef = new FixtureDef();
fixtureDef.restitution = 1f;
fixtureDef.friction = 0f;
fixtureDef.shape = shape;
fixtureDef.filter.categoryBits = Box2DUtil.CAT_BLOCK;
fixtureDef.filter.maskBits = Box2DUtil.MASK_BLOCK;
final Body body = box2d.getWorld().createBody(bodyDef);
body.createFixture(fixtureDef);
shape.dispose();
return body;
}
示例5: Block
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public Block(World world, float x, float f, BodyType type, boolean invisible) {
BodyDef bd = new BodyDef();
bd.type = type;
bd.position.set(x, f);
PolygonShape shape = new PolygonShape();
shape.setAsBox(size / 2, size / 2);
FixtureDef fd = new FixtureDef();
fd.density = 0.1f;
fd.shape = shape;
fd.friction = 0.1f;
fd.filter.groupIndex = Advio.GROUP_DONT_COLLIDE_WITH_PLAYER;
// fd.filter.groupIndex = Advio.GROUP_SCENERY;
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("block"));
this.invisible = invisible;
shape.dispose();
}
示例6: PressurePlate
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public PressurePlate(Level l, World world, float x, float y, float weight, Block[] blocks) {
super(x, y);
this.level = l;
BodyDef bd = new BodyDef();
bd.type = BodyType.KinematicBody;
bd.position.set(x, y);
PolygonShape shape = new PolygonShape();
shape.setAsBox(Block.size / 2, Block.size / 2);
FixtureDef fd = new FixtureDef();
fd.density = 0.0f;
fd.shape = shape;
fd.friction = 0.1f;
fd.isSensor = true;
this.blocks = new ArrayList<Block>(Arrays.asList(blocks));
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("plate").add("pressed", false).add("weight", weight));
shape.dispose();
this.world = world;
}
示例7: AgarLogic
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public AgarLogic(Level l, World world, float x, float y) {
super(x, y);
this.level = l;
BodyDef bd = new BodyDef();
bd.type = BodyType.KinematicBody;
bd.position.set(x, y);
PolygonShape shape = new PolygonShape();
shape.setAsBox(Block.size / 2, Block.size / 2);
FixtureDef fd = new FixtureDef();
fd.density = 0.0f;
fd.shape = shape;
fd.friction = 0.1f;
fd.isSensor = true;
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("agariologic"));
shape.dispose();
this.world = world;
}
示例8: Goal
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public Goal(World world, float x, float y) {
super(x, y);
BodyDef bd = new BodyDef();
bd.type = BodyType.KinematicBody;
bd.position.set(x, y);
PolygonShape shape = new PolygonShape();
shape.setAsBox(Block.size / 2, Block.size / 2);
FixtureDef fd = new FixtureDef();
fd.density = 0.1f;
fd.shape = shape;
fd.friction = 0.1f;
fd.isSensor = true;
// fd.filter.groupIndex = Advio.GROUP_SCENERY;
body = world.createBody(bd);
body.createFixture(fd).setUserData(new UserData("goal"));
shape.dispose();
}
示例9: SpikeEntity
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
/**
* Create some spike
*
* @param world
* @param texture
* @param x horizontal position for the center of the spike (meters)
* @param y vertical position for the base of the spike (meters)
*/
public SpikeEntity(World world, Texture texture, float x, float y) {
this.world = world;
this.texture = texture;
// Create the body.
BodyDef def = new BodyDef(); // (1) Give it some definition.
def.position.set(x, y + 0.5f); // (2) Position the body on the world.
body = world.createBody(def); // (3) Create the body.
// Now give it a shape.
PolygonShape box = new PolygonShape(); // (1) We will make a polygon.
Vector2[] vertices = new Vector2[3]; // (2) However vertices will be manually added.
vertices[0] = new Vector2(-0.5f, -0.5f); // (3) Add the vertices for a triangle.
vertices[1] = new Vector2(0.5f, -0.5f);
vertices[2] = new Vector2(0, 0.5f);
box.set(vertices); // (4) And put them in the shape.
fixture = body.createFixture(box, 1); // (5) Create the fixture.
fixture.setUserData("spike"); // (6) And set the user data to enemy.
box.dispose(); // (7) Destroy the shape when you don't need it.
// Position the actor in the screen by converting the meters to pixels.
setPosition((x - 0.5f) * Constants.PIXELS_IN_METER, y * Constants.PIXELS_IN_METER);
setSize(Constants.PIXELS_IN_METER, Constants.PIXELS_IN_METER);
}
示例10: PlayerEntity
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public PlayerEntity(World world, Texture texture, Vector2 position) {
this.world = world;
this.texture = texture;
// Create the player body.
BodyDef def = new BodyDef(); // (1) Create the body definition.
def.position.set(position); // (2) Put the body in the initial position.
def.type = BodyDef.BodyType.DynamicBody; // (3) Remember to make it dynamic.
body = world.createBody(def); // (4) Now create the body.
// Give it some shape.
PolygonShape box = new PolygonShape(); // (1) Create the shape.
box.setAsBox(0.5f, 0.5f); // (2) 1x1 meter box.
fixture = body.createFixture(box, 3); // (3) Create the fixture.
fixture.setUserData("player"); // (4) Set the user data.
box.dispose(); // (5) Destroy the shape.
// Set the size to a value that is big enough to be rendered on the screen.
setSize(es.danirod.jddprototype.game.Constants.PIXELS_IN_METER, es.danirod.jddprototype.game.Constants.PIXELS_IN_METER);
}
示例11: Player
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public Player(World world, float x, float y, float width, float height) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(x, y);
this.width = width;
this.height = height;
PolygonShape shape = new PolygonShape();
shape.setAsBox(width, height);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
body = world.createBody(bodyDef);
fixture = body.createFixture(fixtureDef);
shape.dispose();
}
示例12: createRectangle
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
/**
*
* @param world
* @param rectangleObject
* @param density
* @param friction
* @param restitution
*/
private void createRectangle(World world, RectangleMapObject rectangleObject, float density, float friction, float restitution){
Rectangle rect = rectangleObject.getRectangle();
PolygonShape shape = new PolygonShape();
shape.setAsBox(rect.width / SupaBox.PPM / 2f, rect.height / SupaBox.PPM / 2f);
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(new Vector2((rect.x + rect.width / 2f) / SupaBox.PPM, (rect.y + rect.height / 2f) / SupaBox.PPM));
Body body = world.createBody(bodyDef);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = density;
fixtureDef.friction = friction;
fixtureDef.restitution = restitution;
body.createFixture(fixtureDef);
shape.dispose();
}
示例13: createIndestructible
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public void createIndestructible(float x, float y, TextureAtlas tileTextureAtlas) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
bodyDef.position.set(x, y);
Body body = b2dWorld.createBody(bodyDef);
PolygonShape polygonShape = new PolygonShape();
polygonShape.setAsBox(0.5f, 0.5f);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = polygonShape;
fixtureDef.filter.categoryBits = GameManager.INDESTRUCTIIBLE_BIT;
fixtureDef.filter.maskBits = GameManager.PLAYER_BIT | GameManager.ENEMY_BIT | GameManager.BOMB_BIT;
body.createFixture(fixtureDef);
polygonShape.dispose();
Renderer renderer = new Renderer(new TextureRegion(tileTextureAtlas.findRegion("indestructible"), 0, 0, 16, 16), 16 / GameManager.PPM, 16 / GameManager.PPM);
renderer.setOrigin(16 / GameManager.PPM / 2, 16 / GameManager.PPM / 2);
new EntityBuilder(world)
.with(
new Transform(x, y, 1f, 1f, 0),
renderer
)
.build();
}
示例14: createRectangleBody
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public static Body createRectangleBody(float x, float y, float width, float height, BodyType type, float density, float friction, float restitution, World world) {
final BodyDef def = new BodyDef();
def.position.set(x, y);
def.type = type;
PolygonShape shape = new PolygonShape();
shape.setAsBox(width / 2, height / 2);
FixtureDef fixt = new FixtureDef();
fixt.shape = shape;
fixt.density = density;
fixt.friction = friction;
fixt.restitution = restitution;
Body bb = world.createBody(def);
bb.createFixture(fixt);
shape.dispose();
return bb;
}
示例15: Bin
import com.badlogic.gdx.physics.box2d.PolygonShape; //导入方法依赖的package包/类
public Bin(World world, float x, float y, float width, float height) {
WIDTH = width;
HEIGHT = height;
this.world = world;
nibolasInside = false;
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(x, y);
bodyDef.fixedRotation = true;
PolygonShape shape = new PolygonShape();
shape.setAsBox(width / 2, height/2);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.restitution = 0;
fixtureDef.friction = 0;
fixtureDef.density = 3;
body = world.createBody(bodyDef);
fixture = body.createFixture(fixtureDef);
shape.dispose();
}