Search in sources :

Example 16 with MapProperties

use of com.badlogic.gdx.maps.MapProperties in project ultimate-java by pantinor.

the class UltimaTiledMapLoader method load.

public TiledMap load() {
    TiledMap map = new TiledMap();
    MapProperties mapProperties = map.getProperties();
    mapProperties.put("name", gameMap.toString());
    mapProperties.put("id", gameMap.getId());
    mapProperties.put("orientation", "orthogonal");
    mapProperties.put("width", mapWidth);
    mapProperties.put("height", mapHeight);
    mapProperties.put("tilewidth", tileWidth);
    mapProperties.put("tileheight", tileHeight);
    mapProperties.put("backgroundcolor", "#000000");
    TiledMapTileLayer layer = new TiledMapTileLayer(mapWidth, mapHeight, tileWidth, tileHeight);
    layer.setName("Map Layer");
    layer.setVisible(true);
    for (int y = 0; y < mapHeight; y++) {
        for (int x = 0; x < mapWidth; x++) {
            Tile ct = gameMap.getMap().getTile(x, y);
            Cell cell = new Cell();
            Array<TextureAtlas.AtlasRegion> tileRegions = atlas.findRegions(ct.getName());
            Array<StaticTiledMapTile> ar = new Array<>();
            for (TextureAtlas.AtlasRegion r : tileRegions) {
                ar.add(new StaticTiledMapTile(r));
            }
            if (ar.size == 0) {
                System.out.println(ct.getName());
            }
            TiledMapTile tmt = null;
            if (tileRegions.size > 1) {
                tmt = new AnimatedTiledMapTile(.7f, ar);
            } else {
                tmt = ar.first();
            }
            tmt.setId(y * mapWidth + x);
            cell.setTile(tmt);
            layer.setCell(x, mapHeight - 1 - y, cell);
        }
    }
    map.getLayers().add(layer);
    if (gameMap.getMap().getType() == MapType.combat) {
        try {
            loadCombatPositions(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return map;
}
Also used : AnimatedTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile) MapProperties(com.badlogic.gdx.maps.MapProperties) AnimatedTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) Tile(objects.Tile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Array(com.badlogic.gdx.utils.Array) TiledMapTileLayer(com.badlogic.gdx.maps.tiled.TiledMapTileLayer) AnimatedTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)

Example 17 with MapProperties

use of com.badlogic.gdx.maps.MapProperties in project ultimate-java by pantinor.

the class GameScreen method loadNextMap.

public void loadNextMap(Maps m, int x, int y, int dngx, int dngy, int dngLevel, Direction orientation, boolean restoreSG) {
    log("Entering " + m.getLabel() + "!");
    BaseMap baseMap = m.getMap();
    if (baseMap.getType() == MapType.dungeon) {
        if (m != Maps.DELVE_SORROWS) {
            DungeonScreen sc = new DungeonScreen(this, context, m);
            if (restoreSG) {
                sc.restoreSaveGameLocation(dngx, dngy, dngLevel, orientation);
            }
            mainGame.setScreen(sc);
        } else {
            StaticGeneratedDungeonScreen sc = new StaticGeneratedDungeonScreen(this, context, m);
            if (restoreSG) {
                sc.restoreSaveGameLocation(dngx, dngy, dngLevel, orientation);
            }
            mainGame.setScreen(sc);
        }
    } else if (baseMap.getType() == MapType.shrine) {
        map = new UltimaTiledMapLoader(m, Ultima4.standardAtlas, baseMap.getWidth(), baseMap.getHeight(), tilePixelWidth, tilePixelHeight).load();
        context.setCurrentTiledMap(map);
        Virtue virtue = Virtue.get(baseMap.getId() - 25);
        ShrineScreen sc = new ShrineScreen(this, context.getParty(), virtue, map, Ultima4.standardAtlas, Ultima4.standardAtlas);
        mainGame.setScreen(sc);
    } else {
        context.setCurrentMap(baseMap);
        baseMap.removeJoinedPartyMemberFromPeopleList(context.getParty());
        map = new UltimaTiledMapLoader(m, Ultima4.standardAtlas, m.getMap().getWidth(), m.getMap().getHeight(), tilePixelWidth, tilePixelHeight).load();
        context.setCurrentTiledMap(map);
        if (renderer != null) {
            renderer.dispose();
        }
        renderer = new UltimaMapRenderer(context, Ultima4.standardAtlas, baseMap, map, 1f);
        mapBatch = renderer.getBatch();
        MapProperties prop = map.getProperties();
        mapPixelHeight = prop.get("height", Integer.class) * tilePixelHeight;
        baseMap.initObjects(this, Ultima4.standardAtlas, Ultima4.standardAtlas);
        renderer.getFOV().calculateFOV(baseMap.getShadownMap(), x, y, 17f);
        newMapPixelCoords = getMapPixelCoords(x, y);
    }
    if (Ultima4.playMusic) {
        if (Ultima4.music != null) {
            Ultima4.music.stop();
        }
        Sound snd = Sound.valueOf(baseMap.getMusic());
        Ultima4.music = Sounds.play(snd, Ultima4.musicVolume);
    }
}
Also used : UltimaTiledMapLoader(util.UltimaTiledMapLoader) UltimaMapRenderer(util.UltimaMapRenderer) MapProperties(com.badlogic.gdx.maps.MapProperties) StaticGeneratedDungeonScreen(generator.StaticGeneratedDungeonScreen) BaseMap(objects.BaseMap) StaticGeneratedDungeonScreen(generator.StaticGeneratedDungeonScreen)

Example 18 with MapProperties

use of com.badlogic.gdx.maps.MapProperties in project Entitas-Java by Rubentxu.

the class Box2DMapObjectParser method createJoint.

/**
 * creates a {@link Joint} from a {@link MapObject}
 *
 * @param mapObject the {@link Joint} to parse
 * @return the parsed {@link Joint}
 */
public Joint createJoint(MapObject mapObject) {
    MapProperties properties = mapObject.getProperties();
    JointDef jointDef = null;
    String type = properties.get("type", String.class);
    if (!type.equals(aliases.joint))
        throw new IllegalArgumentException("type of " + mapObject + " is  \"" + type + "\" instead of \"" + aliases.joint + "\"");
    String jointType = properties.get(aliases.jointType, String.class);
    // get all possible values
    if (jointType.equals(aliases.distanceJoint)) {
        DistanceJointDef distanceJointDef = new DistanceJointDef();
        distanceJointDef.dampingRatio = getProperty(properties, aliases.dampingRatio, distanceJointDef.dampingRatio);
        distanceJointDef.frequencyHz = getProperty(properties, aliases.frequencyHz, distanceJointDef.frequencyHz);
        distanceJointDef.length = getProperty(properties, aliases.length, distanceJointDef.length) * (tileWidth + tileHeight) / 2 * unitScale;
        distanceJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, distanceJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, distanceJointDef.localAnchorA.y) * tileHeight * unitScale);
        distanceJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, distanceJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, distanceJointDef.localAnchorB.y) * tileHeight * unitScale);
        jointDef = distanceJointDef;
    } else if (jointType.equals(aliases.frictionJoint)) {
        FrictionJointDef frictionJointDef = new FrictionJointDef();
        frictionJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, frictionJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, frictionJointDef.localAnchorA.y) * tileHeight * unitScale);
        frictionJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, frictionJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, frictionJointDef.localAnchorB.y) * tileHeight * unitScale);
        frictionJointDef.maxForce = getProperty(properties, aliases.maxForce, frictionJointDef.maxForce);
        frictionJointDef.maxTorque = getProperty(properties, aliases.maxTorque, frictionJointDef.maxTorque);
        jointDef = frictionJointDef;
    } else if (jointType.equals(aliases.gearJoint)) {
        GearJointDef gearJointDef = new GearJointDef();
        gearJointDef.joint1 = joints.get(properties.get(aliases.joint1, String.class));
        gearJointDef.joint2 = joints.get(properties.get(aliases.joint2, String.class));
        gearJointDef.ratio = getProperty(properties, aliases.ratio, gearJointDef.ratio);
        jointDef = gearJointDef;
    } else if (jointType.equals(aliases.mouseJoint)) {
        MouseJointDef mouseJointDef = new MouseJointDef();
        mouseJointDef.dampingRatio = getProperty(properties, aliases.dampingRatio, mouseJointDef.dampingRatio);
        mouseJointDef.frequencyHz = getProperty(properties, aliases.frequencyHz, mouseJointDef.frequencyHz);
        mouseJointDef.maxForce = getProperty(properties, aliases.maxForce, mouseJointDef.maxForce);
        mouseJointDef.target.set(getProperty(properties, aliases.targetX, mouseJointDef.target.x) * tileWidth * unitScale, getProperty(properties, aliases.targetY, mouseJointDef.target.y) * tileHeight * unitScale);
        jointDef = mouseJointDef;
    } else if (jointType.equals(aliases.prismaticJoint)) {
        PrismaticJointDef prismaticJointDef = new PrismaticJointDef();
        prismaticJointDef.enableLimit = getProperty(properties, aliases.enableLimit, prismaticJointDef.enableLimit);
        prismaticJointDef.enableMotor = getProperty(properties, aliases.enableMotor, prismaticJointDef.enableMotor);
        prismaticJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, prismaticJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, prismaticJointDef.localAnchorA.y) * tileHeight * unitScale);
        prismaticJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, prismaticJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, prismaticJointDef.localAnchorB.y) * tileHeight * unitScale);
        prismaticJointDef.localAxisA.set(getProperty(properties, aliases.localAxisAX, prismaticJointDef.localAxisA.x), getProperty(properties, aliases.localAxisAY, prismaticJointDef.localAxisA.y));
        prismaticJointDef.lowerTranslation = getProperty(properties, aliases.lowerTranslation, prismaticJointDef.lowerTranslation) * (tileWidth + tileHeight) / 2 * unitScale;
        prismaticJointDef.maxMotorForce = getProperty(properties, aliases.maxMotorForce, prismaticJointDef.maxMotorForce);
        prismaticJointDef.motorSpeed = getProperty(properties, aliases.motorSpeed, prismaticJointDef.motorSpeed);
        prismaticJointDef.referenceAngle = getProperty(properties, aliases.referenceAngle, prismaticJointDef.referenceAngle);
        prismaticJointDef.upperTranslation = getProperty(properties, aliases.upperTranslation, prismaticJointDef.upperTranslation) * (tileWidth + tileHeight) / 2 * unitScale;
        jointDef = prismaticJointDef;
    } else if (jointType.equals(aliases.pulleyJoint)) {
        PulleyJointDef pulleyJointDef = new PulleyJointDef();
        pulleyJointDef.groundAnchorA.set(getProperty(properties, aliases.groundAnchorAX, pulleyJointDef.groundAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.groundAnchorAY, pulleyJointDef.groundAnchorA.y) * tileHeight * unitScale);
        pulleyJointDef.groundAnchorB.set(getProperty(properties, aliases.groundAnchorBX, pulleyJointDef.groundAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.groundAnchorBY, pulleyJointDef.groundAnchorB.y) * tileHeight * unitScale);
        pulleyJointDef.lengthA = getProperty(properties, aliases.lengthA, pulleyJointDef.lengthA) * (tileWidth + tileHeight) / 2 * unitScale;
        pulleyJointDef.lengthB = getProperty(properties, aliases.lengthB, pulleyJointDef.lengthB) * (tileWidth + tileHeight) / 2 * unitScale;
        pulleyJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, pulleyJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, pulleyJointDef.localAnchorA.y) * tileHeight * unitScale);
        pulleyJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, pulleyJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, pulleyJointDef.localAnchorB.y) * tileHeight * unitScale);
        pulleyJointDef.ratio = getProperty(properties, aliases.ratio, pulleyJointDef.ratio);
        jointDef = pulleyJointDef;
    } else if (jointType.equals(aliases.revoluteJoint)) {
        RevoluteJointDef revoluteJointDef = new RevoluteJointDef();
        revoluteJointDef.enableLimit = getProperty(properties, aliases.enableLimit, revoluteJointDef.enableLimit);
        revoluteJointDef.enableMotor = getProperty(properties, aliases.enableMotor, revoluteJointDef.enableMotor);
        revoluteJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, revoluteJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, revoluteJointDef.localAnchorA.y) * tileHeight * unitScale);
        revoluteJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, revoluteJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, revoluteJointDef.localAnchorB.y) * tileHeight * unitScale);
        revoluteJointDef.lowerAngle = getProperty(properties, aliases.lowerAngle, revoluteJointDef.lowerAngle);
        revoluteJointDef.maxMotorTorque = getProperty(properties, aliases.maxMotorTorque, revoluteJointDef.maxMotorTorque);
        revoluteJointDef.motorSpeed = getProperty(properties, aliases.motorSpeed, revoluteJointDef.motorSpeed);
        revoluteJointDef.referenceAngle = getProperty(properties, aliases.referenceAngle, revoluteJointDef.referenceAngle);
        revoluteJointDef.upperAngle = getProperty(properties, aliases.upperAngle, revoluteJointDef.upperAngle);
        jointDef = revoluteJointDef;
    } else if (jointType.equals(aliases.ropeJoint)) {
        RopeJointDef ropeJointDef = new RopeJointDef();
        ropeJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, ropeJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, ropeJointDef.localAnchorA.y) * tileHeight * unitScale);
        ropeJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, ropeJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, ropeJointDef.localAnchorB.y) * tileHeight * unitScale);
        ropeJointDef.maxLength = getProperty(properties, aliases.maxLength, ropeJointDef.maxLength) * (tileWidth + tileHeight) / 2 * unitScale;
        jointDef = ropeJointDef;
    } else if (jointType.equals(aliases.weldJoint)) {
        WeldJointDef weldJointDef = new WeldJointDef();
        weldJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, weldJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, weldJointDef.localAnchorA.y) * tileHeight * unitScale);
        weldJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, weldJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, weldJointDef.localAnchorB.y) * tileHeight * unitScale);
        weldJointDef.referenceAngle = getProperty(properties, aliases.referenceAngle, weldJointDef.referenceAngle);
        jointDef = weldJointDef;
    } else if (jointType.equals(aliases.wheelJoint)) {
        WheelJointDef wheelJointDef = new WheelJointDef();
        wheelJointDef.dampingRatio = getProperty(properties, aliases.dampingRatio, wheelJointDef.dampingRatio);
        wheelJointDef.enableMotor = getProperty(properties, aliases.enableMotor, wheelJointDef.enableMotor);
        wheelJointDef.frequencyHz = getProperty(properties, aliases.frequencyHz, wheelJointDef.frequencyHz);
        wheelJointDef.localAnchorA.set(getProperty(properties, aliases.localAnchorAX, wheelJointDef.localAnchorA.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorAY, wheelJointDef.localAnchorA.y) * tileHeight * unitScale);
        wheelJointDef.localAnchorB.set(getProperty(properties, aliases.localAnchorBX, wheelJointDef.localAnchorB.x) * tileWidth * unitScale, getProperty(properties, aliases.localAnchorBY, wheelJointDef.localAnchorB.y) * tileHeight * unitScale);
        wheelJointDef.localAxisA.set(getProperty(properties, aliases.localAxisAX, wheelJointDef.localAxisA.x), getProperty(properties, aliases.localAxisAY, wheelJointDef.localAxisA.y));
        wheelJointDef.maxMotorTorque = getProperty(properties, aliases.maxMotorTorque, wheelJointDef.maxMotorTorque);
        wheelJointDef.motorSpeed = getProperty(properties, aliases.motorSpeed, wheelJointDef.motorSpeed);
        jointDef = wheelJointDef;
    }
    jointDef.bodyA = bodies.get(properties.get(aliases.bodyA, String.class));
    jointDef.bodyB = bodies.get(properties.get(aliases.bodyB, String.class));
    jointDef.collideConnected = getProperty(properties, aliases.collideConnected, jointDef.collideConnected);
    Joint joint = jointDef.bodyA.getWorld().createJoint(jointDef);
    String name = mapObject.getName();
    if (joints.containsKey(name)) {
        int duplicate = 1;
        while (joints.containsKey(name + duplicate)) duplicate++;
        name += duplicate;
    }
    joints.put(name, joint);
    return joint;
}
Also used : MapProperties(com.badlogic.gdx.maps.MapProperties)

Example 19 with MapProperties

use of com.badlogic.gdx.maps.MapProperties in project Entitas-Java by Rubentxu.

the class Box2DMapObjectParser method createFixture.

/**
 * creates a {@link Fixture} from a {@link MapObject}
 *
 * @param mapObject the {@link MapObject} to parse
 * @return the parsed {@link Fixture}
 */
public Fixture createFixture(MapObject mapObject) {
    MapProperties properties = mapObject.getProperties();
    String type = properties.get("type", String.class);
    Body body = bodies.get(type.equals(aliases.object) ? mapObject.getName() : properties.get(aliases.body, String.class));
    if (!type.equals(aliases.fixture) && !type.equals(aliases.object))
        throw new IllegalArgumentException("type of " + mapObject + " is  \"" + type + "\" instead of \"" + aliases.fixture + "\" or \"" + aliases.object + "\"");
    FixtureDef fixtureDef = new FixtureDef();
    Shape shape = null;
    if (mapObject instanceof RectangleMapObject) {
        shape = new PolygonShape();
        Rectangle rectangle = new Rectangle(((RectangleMapObject) mapObject).getRectangle());
        rectangle.x *= unitScale;
        rectangle.y *= unitScale;
        rectangle.width *= unitScale;
        rectangle.height *= unitScale;
        ((PolygonShape) shape).setAsBox(rectangle.width / 2, rectangle.height / 2, new Vector2(rectangle.x - body.getPosition().x + rectangle.width / 2, rectangle.y - body.getPosition().y + rectangle.height / 2), body.getAngle());
    } else if (mapObject instanceof PolygonMapObject) {
        shape = new PolygonShape();
        Polygon polygon = ((PolygonMapObject) mapObject).getPolygon();
        polygon.setPosition(polygon.getX() * unitScale - body.getPosition().x, polygon.getY() * unitScale - body.getPosition().y);
        polygon.setScale(unitScale, unitScale);
        ((PolygonShape) shape).set(polygon.getTransformedVertices());
    } else if (mapObject instanceof PolylineMapObject) {
        shape = new ChainShape();
        Polyline polyline = ((PolylineMapObject) mapObject).getPolyline();
        polyline.setPosition(polyline.getX() * unitScale - body.getPosition().x, polyline.getY() * unitScale - body.getPosition().y);
        polyline.setScale(unitScale, unitScale);
        float[] vertices = polyline.getTransformedVertices();
        Vector2[] vectores = new Vector2[vertices.length / 2];
        for (int i = 0, j = 0; i < vertices.length; i += 2, j++) {
            vectores[j].x = vertices[i];
            vectores[j].y = vertices[i + 1];
        }
        ((ChainShape) shape).createChain(vectores);
    } else if (mapObject instanceof CircleMapObject) {
        shape = new CircleShape();
        Circle circle = ((CircleMapObject) mapObject).getCircle();
        circle.setPosition(circle.x * unitScale - body.getPosition().x, circle.y * unitScale - body.getPosition().y);
        circle.radius *= unitScale;
        ((CircleShape) shape).setPosition(new Vector2(circle.x, circle.y));
        ((CircleShape) shape).setRadius(circle.radius);
    } else if (mapObject instanceof EllipseMapObject) {
        Ellipse ellipse = ((EllipseMapObject) mapObject).getEllipse();
        if (ellipse.width == ellipse.height) {
            CircleMapObject circleMapObject = new CircleMapObject(ellipse.x, ellipse.y, ellipse.width / 2);
            circleMapObject.setName(mapObject.getName());
            circleMapObject.getProperties().putAll(mapObject.getProperties());
            circleMapObject.setColor(mapObject.getColor());
            circleMapObject.setVisible(mapObject.isVisible());
            circleMapObject.setOpacity(mapObject.getOpacity());
            return createFixture(circleMapObject);
        }
        IllegalArgumentException exception = new IllegalArgumentException("Cannot parse " + mapObject.getName() + " because  that are not circles are not supported");
        Gdx.app.error(getClass().getName(), exception.getMessage(), exception);
        throw exception;
    } else if (mapObject instanceof TextureMapObject) {
        IllegalArgumentException exception = new IllegalArgumentException("Cannot parse " + mapObject.getName() + " because s are not supported");
        Gdx.app.error(getClass().getName(), exception.getMessage(), exception);
        throw exception;
    } else
        assert false : mapObject + " is a not known subclass of " + MapObject.class.getName();
    fixtureDef.shape = shape;
    fixtureDef.density = getProperty(properties, aliases.density, fixtureDef.density);
    fixtureDef.filter.categoryBits = getProperty(properties, aliases.categoryBits, GRUPO.STATIC.getCategory());
    fixtureDef.filter.groupIndex = getProperty(properties, aliases.groupIndex, fixtureDef.filter.groupIndex);
    fixtureDef.filter.maskBits = getProperty(properties, aliases.maskBits, Box2DPhysicsObject.MASK_STATIC);
    fixtureDef.friction = getProperty(properties, aliases.friciton, fixtureDef.friction);
    fixtureDef.isSensor = getProperty(properties, aliases.isSensor, fixtureDef.isSensor);
    fixtureDef.restitution = getProperty(properties, aliases.restitution, fixtureDef.restitution);
    Fixture fixture = body.createFixture(fixtureDef);
    fixture.setUserData(body.getUserData());
    shape.dispose();
    String name = mapObject.getName();
    if (fixtures.containsKey(name)) {
        int duplicate = 1;
        while (fixtures.containsKey(name + duplicate)) duplicate++;
        name += duplicate;
    }
    fixtures.put(name, fixture);
    return fixture;
}
Also used : MapObject(com.badlogic.gdx.maps.MapObject) MapProperties(com.badlogic.gdx.maps.MapProperties)

Aggregations

MapProperties (com.badlogic.gdx.maps.MapProperties)19 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)10 Cell (com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)10 GameEngine (com.relic.highflyer.GameEngine)7 GameSettings (com.relic.highflyer.GameSettings)7 GameState (com.relic.highflyer.GameState)7 ScreenManager (com.relic.highflyer.screens.ScreenManager)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)5 AnimatedTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile)4 Array (com.badlogic.gdx.utils.Array)4 Element (com.badlogic.gdx.utils.XmlReader.Element)4 Screen (com.badlogic.gdx.Screen)3 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)3 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)3 TiledMapTileLayer (com.badlogic.gdx.maps.tiled.TiledMapTileLayer)3 Tile (objects.Tile)3 FileHandle (com.badlogic.gdx.files.FileHandle)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2