本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Shape.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java Shape.dispose方法的具体用法?Java Shape.dispose怎么用?Java Shape.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.Shape
的用法示例。
在下文中一共展示了Shape.dispose方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEntityBody
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的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: createStaticInteractionBody
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
/**
* Erzeugt automatisch aus einem MapObject einen statischen Trigger.
*
* @see InteractionHandler#createInteractionFixture(Body, Shape)
*
* @param mapObject das MapObject
*/
public void createStaticInteractionBody(MapObject mapObject)
{
Shape shape = PhysicsTileMapBuilder.createShape(mapObject, PhysicsTileMapBuilder.TYPE_TRIGGER);
if (shape == null)
{
Gdx.app.log("WARNING", "Unkown trigger type! The interaction object " + mapObject.getName() + " will be ignored!");
return;
}
BodyDef triggerDef = new BodyDef();
triggerDef.type = BodyDef.BodyType.StaticBody;
Body trigger = manager.getPhysicalWorld().createBody(triggerDef);
createInteractionFixture(trigger, shape);
shape.dispose();
}
示例3: createStaticAttackBody
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
/**
* Erzeugt automatisch aus einem MapObject einen statischen Trigger.
*
* @see AttackHandler#createAttackFixture(Body, Shape)
*
* @param mapObject das MapObject
*/
public void createStaticAttackBody(MapObject mapObject)
{
Shape shape = PhysicsTileMapBuilder.createShape(mapObject, PhysicsTileMapBuilder.TYPE_TRIGGER);
if (shape == null)
{
Gdx.app.log("WARNING", "Unkown trigger type! The attack object " + mapObject.getName() + " will be ignored!");
return;
}
BodyDef triggerDef = new BodyDef();
triggerDef.type = BodyDef.BodyType.StaticBody;
Body trigger = manager.getPhysicalWorld().createBody(triggerDef);
createAttackFixture(trigger, shape);
shape.dispose();
}
示例4: createDynamicBody
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
public Body createDynamicBody(float posX, float posY, Shape shape,
float density, float friction, float restitution) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.set(posX, posY);
Body body = world.createBody(bodyDef);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.friction = friction;
fixtureDef.density = density;
fixtureDef.restitution = restitution;
Fixture fixture = body.createFixture(fixtureDef);
shape.dispose();
return body;
}
示例5: onInit
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
/**
* Erstellt einen Box2D Körper und macht ihm zum Sensor.
*/
@Override
public void onInit()
{
World world = worldObjectManager.getPhysicalWorld();
Shape shape = PhysicsTileMapBuilder.createShape(rawObject, PhysicsTileMapBuilder.TYPE_TRIGGER);
if (shape == null)
{
Gdx.app.log("WARNING", "Unkown trigger type! The trigger " + objectId + " will be ignored!");
return;
}
BodyDef triggerDef = new BodyDef();
triggerDef.type = BodyDef.BodyType.StaticBody;
trigger = world.createBody(triggerDef);
FixtureDef fixture = new FixtureDef();
fixture.shape = shape;
fixture.isSensor = true;
fixture.filter.categoryBits = Physics.CATEGORY_TRIGGER;
fixture.filter.maskBits = Physics.MASK_TRIGGER;
trigger.createFixture(fixture).setUserData(this);
shape.dispose();
}
示例6: buildBodiesFromLayer
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
/**
* Erzeugt aus einem ObjectLayer Box2D Körper.
*
* @param layer die Ebene
* @param world die Box2D Welt
*/
public static void buildBodiesFromLayer(MapLayer layer, World world)
{
for(MapObject tileObject : layer.getObjects())
{
if (
tileObject instanceof TextureMapObject ||
tileObject instanceof CircleMapObject ||
tileObject instanceof EllipseMapObject)
continue;
Shape shape = createShape(tileObject, TYPE_COLLISION);
if (shape == null)
continue;
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
Body body = world.createBody(bodyDef);
FixtureDef fixture = new FixtureDef();
fixture.shape = shape;
fixture.filter.categoryBits = Physics.CATEGORY_WORLD;
fixture.filter.maskBits = Physics.MASK_WORLD;
body.createFixture(fixture);
shape.dispose();
}
}
示例7: claim
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
@Override
public boolean claim(WorldRoom parent) {
if (this.parent == null) {
this.parent = parent;
String[] defShape = this.mapEntrypoint.split(":");
this.bodyData = this.parent.getMap().getDefinedShape(defShape[0], defShape[1]);
if (this.spawnPoint == null) {
String rawPoint = this.parent.getMap().getEntrypointSpawn(this.mapEntrypoint);
if (rawPoint != null && !rawPoint.trim().isEmpty()) {
String[] defPoint = rawPoint.split(":");
this.spawnPoint =
this.parent.getMap().getDefinedPoint(defPoint[0], defPoint[1]);
}
}
if (this.bodyData != null) {
float ptm = OverworldController.PIXELS_TO_METERS;
BodyDef def = new BodyDef();
def.type = BodyType.StaticBody;
def.position.set(bodyData.getPosition());
def.position.x = def.position.x * ptm;
def.position.y = def.position.y * ptm;
Shape shape = bodyData.generateShape();
this.body = parent.getOverworld().getCollisionHandler().getWorld().createBody(def);
this.body.createFixture(shape, 0F);
this.body.setUserData(this);
shape.dispose();
}
return true;
}
return false;
}
示例8: createFixture
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
private static final Fixture createFixture(Body body, Shape shape){
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = 1f;
Fixture fixture = body.createFixture(fixtureDef);
shape.dispose();
return fixture;
}
示例9: crearColisiones
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
private void crearColisiones() {
Array<Body> slopes = new Array<Body>();
FixtureDef fixDef = new FixtureDef();
MapObjects objects = cls.getObjects();
Iterator<MapObject> objectIt = objects.iterator();
while(objectIt.hasNext()) {
MapObject object = objectIt.next();
if (object instanceof TextureMapObject){
continue;
}
Shape shape;
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
if (object instanceof RectangleMapObject) {
RectangleMapObject rectangle = (RectangleMapObject)object;
shape = getRectangle(rectangle);
}
else if (object instanceof PolygonMapObject) {
shape = getPolygon((PolygonMapObject)object);
}
else if (object instanceof PolylineMapObject) {
shape = getPolyline((PolylineMapObject)object);
}
else if (object instanceof EllipseMapObject) {
shape = getEllipse((EllipseMapObject)object);
}
else if (object instanceof CircleMapObject) {
shape = getCircle((CircleMapObject)object);
}
else {
continue;
}
fixDef.shape = shape;
fixDef.filter.categoryBits = GameWorld.BIT_PARED;
fixDef.filter.maskBits = GameWorld.BIT_JUGADOR | GameWorld.BIT_ENEMIGOS | GameWorld.BIT_SENSOR;
Body suelo = GameWorld.mundo.createBody(bodyDef);
suelo.createFixture(fixDef).setUserData("cls");
slopes.add(suelo);
shape.dispose();
}
}
示例10: createPhysics
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
/**
* @param map map to be used to create the static bodies.
* @param layerName name of the layer that contains the shapes.
*/
public void createPhysics(Map map, String layerName) {
MapLayer layer = map.getLayers().get(layerName);
if (layer == null) {
logger.error("layer " + layerName + " does not exist");
return;
}
MapObjects objects = layer.getObjects();
Iterator<MapObject> objectIt = objects.iterator();
while(objectIt.hasNext()) {
MapObject object = objectIt.next();
if (object instanceof TextureMapObject){
continue;
}
Shape shape;
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
if (object instanceof RectangleMapObject) {
RectangleMapObject rectangle = (RectangleMapObject)object;
shape = getRectangle(rectangle);
}
else if (object instanceof PolygonMapObject) {
shape = getPolygon((PolygonMapObject)object);
}
else if (object instanceof PolylineMapObject) {
shape = getPolyline((PolylineMapObject)object);
}
else if (object instanceof CircleMapObject) {
shape = getCircle((CircleMapObject)object);
}
else {
logger.error("non suported shape " + object);
continue;
}
MapProperties properties = object.getProperties();
String material = properties.get("material", "default", String.class);
FixtureDef fixtureDef = materials.get(material);
if (fixtureDef == null) {
logger.error("material does not exist " + material + " using default");
fixtureDef = materials.get("default");
}
fixtureDef.shape = shape;
fixtureDef.filter.categoryBits = Env.game.getCategoryBitsManager().getCategoryBits("level");
Body body = world.createBody(bodyDef);
body.createFixture(fixtureDef);
bodies.add(body);
fixtureDef.shape = null;
shape.dispose();
}
}
示例11: queueBoundingShape
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
/**
* Queues a {@link Shape} to be set as a {@link Fixture}
* on this {@link WorldObject}'s body.
*
* <p>If the body is ready, this method immediately
* applies the Shape as a Fixture.</p>
*
* <p>Note: Do <strong>NOT</strong> dispose of the Shape
* after sending it to this method. This method
* <strong>will automatically dispose of the
* Shape</strong> after it has been applied to this
* WorldObject's body. Disposing of the shape after
* passing to this method will crash the Java Virtual
* Machine, as Shapes are written in C++ JNI.</p>
*
* @param shape the shape to apply as a bounding shape,
* do not dispose after passing to this method
*/
public void queueBoundingShape(Shape shape) {
if (this.body != null) {
this.body.createFixture(shape, 0F);
shape.dispose();
} else if (this.boundingQueue != null) {
this.boundingQueue.add(shape);
}
}
示例12: createStaticBody
import com.badlogic.gdx.physics.box2d.Shape; //导入方法依赖的package包/类
public Body createStaticBody(Vector2 position, Shape shape, float density) {
BodyDef bodyDef = new BodyDef();
bodyDef.position.set(position);
Body body = world.createBody(bodyDef);
body.createFixture(shape, density);
shape.dispose();
return body;
}