Example usage for com.badlogic.gdx.physics.box2d World destroyBody

List of usage examples for com.badlogic.gdx.physics.box2d World destroyBody

Introduction

In this page you can find the example usage for com.badlogic.gdx.physics.box2d World destroyBody.

Prototype

public void destroyBody(Body body) 

Source Link

Document

Destroy a rigid body given a definition.

Usage

From source file:com.jmolina.orb.elements.Element.java

License:Open Source License

/**
 * Libera los recursos del elemento. Elimina al actor de su stage y al cuerpo de su mundo.
 * Anula las referencias.//from   w w  w  . jav  a  2s. c  om
 */
public void dispose() {
    World world = getBody().getWorld();
    world.destroyBody(getBody());
    getActor().remove();

    assetManager = null;
    actor = null;
}

From source file:com.mygdx.game.TiledMapHelper.java

License:Apache License

public void createCameraLimit(World world, float a) {

    limitCameraLeft = a;//w ww  .j a  va 2 s  . c  om
    limitCameraRight = limitCameraLeft + 8.8f;

    if (getScreenLimits().size != 0) {
        for (Body screen : getScreenLimits()) {
            world.destroyBody(screen);
            screen.setUserData(null);
        }
        getScreenLimits().clear();
    }

    //Colisions limits esquerra camera
    BodyDef bodyDef2 = new BodyDef();
    bodyDef2.type = BodyDef.BodyType.StaticBody;
    bodyDef2.position.set(0, 0);
    FixtureDef fixtureDef2 = new FixtureDef();
    EdgeShape edgeShape = new EdgeShape();
    edgeShape.set(limitCameraLeft, 0, limitCameraLeft, camera.position.y);

    /*Gdx.app.log("ViewPort height", String.valueOf(camera.viewportHeight));
    Gdx.app.log("ViewPort width",String.valueOf(camera.viewportWidth));
    Gdx.app.log("Position x",String.valueOf(camera.position.x));
    Gdx.app.log("Position y", String.valueOf(camera.position.y));*/

    fixtureDef2.shape = edgeShape;
    fixtureDef2.filter.categoryBits = ColisionsGroups.MAP_ENTITY;
    fixtureDef2.filter.maskBits = ColisionsGroups.HERO_ENTITY | ColisionsGroups.ENEMIC_ENTITY;
    Body bodyEdgeScreenLeft = world.createBody(bodyDef2);
    bodyEdgeScreenLeft.createFixture(fixtureDef2);
    bodyEdgeScreenLeft.setUserData(LEFT_SCREEN_LIMIT);
    getScreenLimits().add(bodyEdgeScreenLeft);
    fixtureDef2.shape = null;
    edgeShape.dispose();

    //Colisions limit dret camera
    BodyDef bodyDef4 = new BodyDef();
    bodyDef4.type = BodyDef.BodyType.StaticBody;
    bodyDef4.position.set(0, 0);
    FixtureDef fixtureDef4 = new FixtureDef();
    EdgeShape edgeShapeRight = new EdgeShape();
    edgeShapeRight.set(limitCameraRight, 0, limitCameraRight, camera.position.y);
    fixtureDef4.shape = edgeShapeRight;
    fixtureDef4.filter.categoryBits = ColisionsGroups.MAP_ENTITY;
    fixtureDef4.filter.maskBits = ColisionsGroups.HERO_ENTITY | ColisionsGroups.ENEMIC_ENTITY;
    ;
    Body bodyEdgeScreenRight = world.createBody(bodyDef4);
    bodyEdgeScreenRight.createFixture(fixtureDef4);
    bodyEdgeScreenRight.setUserData(RIGHT_SCREEN_LIMIT);
    getScreenLimits().add(bodyEdgeScreenRight);
    fixtureDef4.shape = null;
    edgeShapeRight.dispose();

}

From source file:com.strategames.engine.gameobject.GameObject.java

License:Open Source License

public void deleteBody(World world) {
    synchronized (body) {
        world.destroyBody(body);
        body.setUserData(null);/*w  w  w .  j a v  a 2  s.  c om*/
        body = null;
    }
}

From source file:com.tnf.ptm.entities.ship.Door.java

License:Apache License

public void onRemove(PtmGame game) {
    World w = game.getObjMan().getWorld();
    Body doorBody = getBody();
    w.destroyJoint(myJoint);
    w.destroyBody(doorBody);
}

From source file:org.destinationsol.game.ship.Door.java

License:Apache License

public void onRemove(SolGame game) {
    World w = game.getObjMan().getWorld();
    Body doorBody = getBody();
    w.destroyJoint(myJoint);
    w.destroyBody(doorBody);
}

From source file:org.loon.framework.android.game.physics.LBody.java

License:Apache License

public void removeFromWorld(LWorld world) {
    World jboxWorld = world.getBox2DWorld();
    jboxWorld.destroyBody(this.jboxBody);
}

From source file:project.LqPhysicsBox.java

public void destroy() {
    World parentWorld = body.getWorld();
    parentWorld.destroyBody(getBody());
}