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

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

Introduction

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

Prototype

public boolean getAutoClearForces() 

Source Link

Document

Get the flag that controls automatic clearing of forces after each time step.

Usage

From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java

License:Apache License

/** creates the given {@link Map Map's} {@link MapObjects} in the given {@link World}
 *  @param world the {@link World} to create the {@link MapObjects} of the given {@link Map} in
 *  @param map the {@link Map} which {@link MapObjects} to create in the given {@link World}
 *  @return the given {@link World} with the parsed {@link MapObjects} of the given {@link Map} created in it */
public World load(World world, Map map) {
    MapProperties oldMapProperties = mapProperties;
    mapProperties = map.getProperties();

    world.setGravity(vec2.set(getProperty(mapProperties, aliases.gravityX, world.getGravity().x),
            getProperty(mapProperties, aliases.gravityY, world.getGravity().y)));
    world.setAutoClearForces(getProperty(mapProperties, aliases.autoClearForces, world.getAutoClearForces()));

    if (!ignoreMapUnitScale)
        unitScale = getProperty(mapProperties, aliases.unitScale, unitScale);
    tileWidth = getProperty(mapProperties, aliases.tileWidth, tileWidth);
    tileHeight = getProperty(mapProperties, aliases.tileHeight, tileHeight);

    listener.init(this);

    @SuppressWarnings("unchecked")
    Array<MapLayer> layers = Pools.obtain(Array.class);
    layers.clear();/*  w w  w . j  a  va  2  s.c o m*/
    listener.load(map, layers);

    for (MapLayer mapLayer : layers)
        load(world, mapLayer);

    layers.clear();
    Pools.free(layers);

    mapProperties = oldMapProperties;
    return world;
}

From source file:net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java

License:Apache License

/** creates the given {@link Map Map's} {@link MapObjects} in the given {@link World}  
 *  @param world the {@link World} to create the {@link MapObjects} of the given {@link Map} in
 *  @param map the {@link Map} which {@link MapObjects} to create in the given {@link World}
 *  @return the given {@link World} with the parsed {@link MapObjects} of the given {@link Map} created in it */
public World load(World world, Map map) {
    MapProperties oldMapProperties = mapProperties;
    mapProperties = map.getProperties();

    world.setGravity(vec2.set(getProperty(mapProperties, aliases.gravityX, world.getGravity().x),
            getProperty(mapProperties, aliases.gravityY, world.getGravity().y)));
    world.setAutoClearForces(getProperty(mapProperties, aliases.autoClearForces, world.getAutoClearForces()));

    if (!ignoreMapUnitScale)
        unitScale = getProperty(mapProperties, aliases.unitScale, unitScale);
    tileWidth = getProperty(mapProperties, aliases.tileWidth, tileWidth);
    tileHeight = getProperty(mapProperties, aliases.tileHeight, tileHeight);

    for (MapLayer mapLayer : map.getLayers())
        load(world, mapLayer);/* w  w  w . j  a  v a  2  s.c  o  m*/

    mapProperties = oldMapProperties;
    return world;
}