Example usage for com.badlogic.gdx.maps.objects TextureMapObject getProperties

List of usage examples for com.badlogic.gdx.maps.objects TextureMapObject getProperties

Introduction

In this page you can find the example usage for com.badlogic.gdx.maps.objects TextureMapObject getProperties.

Prototype

public MapProperties getProperties() 

Source Link

Usage

From source file:releasethekraken.entity.EntityPowerUp.java

public EntityPowerUp(GameWorld world, TextureMapObject mapObject) {
    super(world, mapObject);
    this.type = Ability.valueOf(mapObject.getProperties().get("PowerupType", String.class));
    this.despawnTimer = mapObject.getProperties().get("Despawn", Integer.class);
}

From source file:rosthouse.rosty.loader.MapLoader.java

private void createTexture(TextureMapObject texture, PhysicsSystem physicsSystem, Entity mapObjectEntity,
        boolean isSensor) {
    SpriteComponent spriteComponent = new SpriteComponent(texture.getTextureRegion());
    PositionComponent positionComponent = new PositionComponent();

    float width = texture.getProperties().get("width", Float.class);
    float height = texture.getProperties().get("height", Float.class);
    float rotation = texture.getRotation();
    float x = texture.getX();
    float y = texture.getY() + height;

    String name = texture.getName();
    spriteComponent.sprite.setOrigin(texture.getOriginX() - width * 0.5f, texture.getOriginY() - height * 0.5f);
    spriteComponent.sprite.setSize(width, height);
    PolygonShape polygonShape = new PolygonShape();
    polygonShape.setAsBox(width * 0.5f, height * 0.5f, new Vector2(width * 0.5f, height * 0.5f),
            MathUtils.degreesToRadians * rotation);
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = 0;/*  w w w  . j  ava  2s.com*/
    fixtureDef.friction = 1;
    fixtureDef.restitution = 0.2f;

    PhysicsComponent<PolygonShape> cmpSensor;
    if (isSensor) {
        cmpSensor = physicsSystem.createSensorComponent(BodyDef.BodyType.StaticBody, polygonShape,
                new Vector2(x, y), fixtureDef);
    } else {
        cmpSensor = physicsSystem.createPhysicsComponent(BodyDef.BodyType.StaticBody, polygonShape,
                new Vector2(x, y), fixtureDef);
    }
    cmpSensor.fixture.getBody().setTransform(x, y, MathUtils.degreesToRadians * rotation);
    mapObjectEntity.add(cmpSensor);
    cmpSensor.fixture.setUserData(mapObjectEntity.getId());
    mapObjectEntity.add(spriteComponent);
    mapObjectEntity.add(positionComponent);
}