Java 类com.badlogic.gdx.maps.MapObject 实例源码

项目:KyperBox    文件:GameState.java   
private void loadFonts(TiledMap data, String atlasname) {
    MapObjects objects = data.getLayers().get("preload").getObjects();
    String ffcheck = "Font";
    for (MapObject o : objects) {
        String name = o.getName();
        BitmapFont font = null;
        MapProperties properties = o.getProperties();
        String type = properties.get("type", String.class);
        String fontfile = properties.get("font_file", String.class);
        if (fontfile != null && type != null && type.equals(ffcheck)) {
            boolean markup = properties.get("markup", false, boolean.class);
            game.loadFont(fontfile, atlasname);
            game.getAssetManager().finishLoading();
            font = game.getFont(fontfile);
            fonts.put(name, font);
            font.getData().markupEnabled = markup;
        }
    }
}
项目:KyperBox    文件:GameState.java   
private void loadParticleEffects(TiledMap data, String atlasname) {
    MapObjects objects = data.getLayers().get("preload").getObjects();
    String ppcheck = "Particle";
    for (MapObject o : objects) {
        String name = o.getName();
        MapProperties properties = o.getProperties();
        String type = properties.get("type", String.class);
        if (type != null && type.equals(ppcheck)) {
            String file = properties.get("particle_file", String.class);
            if (file != null) {
                game.loadParticleEffect(file, atlasname);
                game.getAssetManager().finishLoading();
                if (!particle_effects.containsKey(name)) {
                    ParticleEffect pe = game.getParticleEffect(file);
                    pe.setEmittersCleanUpBlendFunction(false);
                    pvalues.add(KyperBoxGame.PARTICLE_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
                    particle_effects.put(name, new ParticleEffectPool(pe, 12, 48));
                }
            }
        }
    }
}
项目:KyperBox    文件:GameState.java   
private void loadShaders(TiledMap data) {
    MapObjects objects = data.getLayers().get("preload").getObjects();
    String scheck = "Shader";
    for (MapObject o : objects) {
        String name = o.getName();
        MapProperties properties = o.getProperties();
        String type = properties.get("type", String.class);
        if (type != null && type.equals(scheck)) {
            String file = properties.get("shader_name", String.class);
            if (file != null) {
                game.loadShader(file);
                game.getAssetManager().finishLoading();
                if (!shaders.containsKey(name)) {
                    ShaderProgram sp = game.getShader(file);
                    shaders.put(name, sp);
                    svalues.add(KyperBoxGame.SHADER_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
                }
            }
        }
    }
}
项目:school-game    文件:InteractionHandler.java   
/**
 * 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();
}
项目:school-game    文件:AttackHandler.java   
/**
 * 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();
}
项目:school-game    文件:PhysicsTileMapBuilder.java   
/**
 * Erzeugt eine Form aus einem MapObject.
 *
 * @param mapObject das MapObject
 * @param mask Bitmaske, um Shape Typen auszuschließen
 * @return die entsprechende Form
 */
public static Shape createShape(MapObject mapObject, short mask)
{
    Shape shape = null;

    if (mapObject instanceof RectangleMapObject && (mask & TYPE_RECTANGLE) != 0)
    {
        shape = PhysicsTileMapBuilder.createRectangle((RectangleMapObject) mapObject);
    }
    else if (mapObject instanceof PolygonMapObject && (mask & TYPE_POLYGON) != 0)
    {
        shape = PhysicsTileMapBuilder.createPolygon((PolygonMapObject) mapObject);
    }
    else if (mapObject instanceof EllipseMapObject && (mask & TYPE_CIRCLE) != 0)
    {
        shape = PhysicsTileMapBuilder.createCircle((EllipseMapObject) mapObject);
    }
    else if (mapObject instanceof PolylineMapObject && (mask & TYPE_POLYLINE) != 0)
    {
        shape = createPolyline((PolylineMapObject) mapObject);
    }

    return shape;
}
项目:GangsterSquirrel    文件:Box2DWorldCreator.java   
/**
 * Reads the enemy type and spawn position out of an enemy object on the map and then spawns it in the current level
 * @param object the map object that has been read in the map file
 * @param rectangle the rectangular shape of the object, contains position used for selecting the spawn position
 */
private void addEnemy(MapObject object, Rectangle rectangle) {

    MapProperties properties = object.getProperties();

    if (properties != null && properties.containsKey("enemy_type")) {
        String enemyType = properties.get("enemy_type", String.class);

        switch (enemyType) {
            case "Frog":
                playScreen.spawnEnemy(FrogEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
                break;
            case "Monkey":
                playScreen.spawnEnemy(MonkeyEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
                break;
            case "Boss":
                playScreen.spawnEnemy(BossEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
                break;
            default:
                break;
        }
    }
}
项目:QuackHack    文件:Box.java   
public Box(World world, MapObject object){
    super(Assets.getAtlas().findRegion("boxCrate_double"));
    Rectangle rect = ((RectangleMapObject) object).getRectangle();
    bdef.type = BodyDef.BodyType.DynamicBody;
    bdef.position.set((rect.getX()+rect.getWidth()/2)/ QuackHack.PPM, (rect.getY() + rect.getHeight()/2)/QuackHack.PPM); // I don't follow the math
    body = world.createBody(bdef);

    shape.setAsBox(rect.getWidth() / 2 / QuackHack.PPM, rect.getHeight() / 2 / QuackHack.PPM);
    fdef.shape = shape;
    fdef.friction = 0.4f;
    fdef.density = 0.1f;
    body.createFixture(fdef);

    boxRegion = new TextureRegion(getTexture(), 0, 0, 128, 128);
    setBounds(0,0, 128 / QuackHack.PPM, 128 / QuackHack.PPM);
    setRegion(boxRegion);
    setOrigin(getHeight()/2, getWidth()/2);
}
项目:rbcgj-2016    文件:MapActionHandler.java   
public void load(TiledMap map) {
    MapProperties properties = map.getProperties();
    width = (Integer) properties.get(Tmx.WIDTH);
    height = (Integer) properties.get(Tmx.HEIGHT);
    objects = new MapObject[width][height];
    portals.clear();

    for (MapLayer layer : map.getLayers()) {
        for (MapObject object : layer.getObjects()) {
            if (object.getProperties().get("portal-id") != null) {
                portals.put((String) object.getProperties().get("portal-id"), object);
            }
            MapProperties objectProperties = object.getProperties();
            float x = (Float) objectProperties.get("x");
            float y = (Float) objectProperties.get("y");
            int indexX = (int) Math.floor(x / GameConfig.CELL_SCALE);
            int indexY = (int) Math.floor(y / GameConfig.CELL_SCALE);
            if (indexX >= 0 && indexY >= 0 && indexX < width && indexY < height) {
                objects[indexX][indexY] = object;
            }
        }
    }
}
项目:rbcgj-2016    文件:CrumbCollector.java   
@Override
public void onObjectEnter(GameObject object, MapProperties properties, MapActionHandler.MapAPI api) {
    int indexX = (int)Math.floor(object.getLeft() / GameConfig.CELL_SCALE);
    int indexY = (int)Math.floor(object.getTop() / GameConfig.CELL_SCALE);
    MapObject o = api.getObjectAt(indexX, indexY);
    if (o != null) {
        GameObject gameObject = levelManager.getGameObjectByMapObject(o);
        if (gameObject != null) {
            playerManager.addCollectible(GameObjectType.CRUMB);
            api.removeObjectAt(indexX, indexY);
            world.remove(gameObject);
            AssetManager.getSound(Assets.Sounds.COLLECT_NUT).play();
            Tooltip.getInstance().create(object.getLeft() + object.getWidth() * 2f, object.getTop() + object.getHeight() * 3f, Styles.STORY, "nom..", Colors.INFO, null);
        }
    }
}
项目:joe    文件:TiledMapLevelLoadable.java   
public TiledMapLevelLoadable(int levelId) {
    this.id = levelId;

    respawnPosition = new Vector2();
    freeBodyDefinitions = new Array<FixtureBodyDefinition>();
    entityDefinitions = new Array<EntityDefinition>();
    scriptDefinitions = new Array<ScriptDefinition>();
    canvasMap = new LinkedHashMap<IRender, Integer>();
    bodySkeletonMap = new HashMap<String, MapObject>();

    String tileMapName = Globals.getLevelTileMapName(levelId);
    filename = AssetManager.getFilePath("levels", tileMapName + ".tmx");
    TmxMapLoader.Parameters params = new TmxMapLoader.Parameters();
    params.flipY = false;

    tiledMap = new TmxMapLoader().load(filename, params);

    background = new ParallaxBackground();
    setBackground();

    processLayers();
}
项目:joe    文件:TiledMapLevelLoadable.java   
private void processFreeBodies(Array<MapObject> bodies) {
    for (MapObject object : bodies) {
        FixtureBodyDefinition fixtureBodyDefinition;
        if (object instanceof RectangleMapObject) {
            fixtureBodyDefinition = TiledUtils.createRectangleFixtureBodyDef((RectangleMapObject)object);
        } else if (object instanceof CircleMapObject) {
            fixtureBodyDefinition = TiledUtils.createCircleFixtureBodyDef((CircleMapObject)object);
        } else if (object instanceof EllipseMapObject) {
            fixtureBodyDefinition = TiledUtils.createEllipseFixtureBodyDef((EllipseMapObject)object);
        } else if (object instanceof PolylineMapObject || object instanceof PolygonMapObject) {
            fixtureBodyDefinition = TiledUtils.createPolyFixtureBodyDef(object);
        } else {
            throw new InvalidConfigException(filename, "Unknown MapObject type");
        }

        freeBodyDefinitions.add(fixtureBodyDefinition);
    }
}
项目:joe    文件:TiledUtils.java   
public static FixtureDef getFixtureDefFromBodySkeleton(MapObject object) {
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = 1;
    fixtureDef.friction = 0;
    fixtureDef.restitution = 0;

    Shape shape = null;
    if (object instanceof TextureMapObject) {
        shape = getTextureMapShape(object);
    } else if (object instanceof RectangleMapObject) {
        shape = getRectangleShape(object);
    } else if (object instanceof CircleMapObject) {
        shape = getCircleShape(object);
    } else if (object instanceof EllipseMapObject) {
        shape = getEllipseShape(object);
    } else if (object instanceof PolygonMapObject) {
        shape = getPolygonShape(object);
    } else if (object instanceof PolylineMapObject) {
        shape = getPolylineShape(object);
    }

    fixtureDef.shape = shape;

    return fixtureDef;
}
项目:Quilly-s-Castle    文件:Map.java   
private void parseCollisionLayer() {
if (collisionLayer == null) {
    Gdx.app.debug(TAG, "No collision layer!");
    return;
}

for (MapObject object : collisionLayer.getObjects()) {
    if (object instanceof RectangleMapObject) {
    Rectangle rect = ((RectangleMapObject) object).getRectangle();
    rect.set( // update Tiled editor real values with our game world values
        rect.x * GameWorld.UNIT_SCALE, // scale x
        rect.y * GameWorld.UNIT_SCALE, // scale y
        rect.width * GameWorld.UNIT_SCALE, // scale width
        rect.height * GameWorld.UNIT_SCALE // scale height
    );
    }
}
   }
项目:Quilly-s-Castle    文件:Map.java   
private void parseSpawnLayer() {
if (spawnsLayer == null) {
    Gdx.app.debug(TAG, "No spawn layer!");
    return;
}

for (MapObject object : spawnsLayer.getObjects()) {
    if (object instanceof RectangleMapObject) {
    entities.add(Entity.getEntity( // params
        EntityType.valueOf(object.getName()), // entity type
        ((RectangleMapObject) object).getRectangle().x * GameWorld.UNIT_SCALE, // start x
        ((RectangleMapObject) object).getRectangle().y * GameWorld.UNIT_SCALE // start y
    ));
    }
}
   }
项目:fabulae    文件:GameMapLoader.java   
private void loadCharacterGroups() throws IOException {
    MapLayer groupsLayer = map.getLayers().get(LAYER_GROUPS);
    if (groupsLayer == null) {
        return;
    }
    MapObjects groups = groupsLayer.getObjects();
    for (MapObject mapGroup : groups) {
        if (mapGroup.getName() == null) {
            continue;
        }
        String groupFile = mapGroup.getName();
        String id = (String) mapGroup.getProperties().get(PROPERTY_ID);
        if (id == null) {
            id = groupFile;
        }

        Vector2 position = getPositionFromMapObject(mapGroup);
        CharacterGroupGameObject group = new CharacterGroupGameObject(id, Gdx.files.internal(Configuration
                .getFolderGroups() + groupFile + ".xml"), gameMap);
        group.position().set((int) (position.x / gameMap.getTileSizeX()),
                (int) (position.y / gameMap.getTileSizeY()));
    }
}
项目:fabulae    文件:GameMapLoader.java   
private void loadItems() throws IOException {
    MapLayer itemsLayer = map.getLayers().get(LAYER_ITEMS);
    if (itemsLayer == null) {
        return;
    }
    MapObjects items = itemsLayer.getObjects();
    for (MapObject item : items) {
        Vector2 position = getPositionFromMapObject(item);
        PickableGameObject newItem = new PickableGameObject(item.getName());
        newItem.getOwner().set(item.getProperties().get(PROPERTY_OWNER_CHARACTER, String.class),
                Faction.getFaction(item.getProperties().get(PROPERTY_OWNER_FACTION, String.class)),
                Boolean.valueOf(item.getProperties().get(PROPERTY_OWNER_FIXED, "false", String.class)));
        newItem.position().set(position.x / gameMap.getTileSizeX(), position.y / gameMap.getTileSizeY());
        newItem.setMap(gameMap);
        newItem.setOffsets(newItem.getXOffset() + getInteger(item, PROPERTY_XOFFSET, 0) * gameMap.getScaleX(),
                newItem.getYOffset() + getInteger(item, PROPERTY_YOFFSET, 0) * gameMap.getScaleY());
    }
}
项目:fabulae    文件:GameMapLoader.java   
private void loadLocations(MapLayer locationsLayer, boolean loadTraps) throws IOException {
    if (locationsLayer == null) {
        return;
    }
    MapObjects locations = locationsLayer.getObjects();
    for (MapObject location : locations) {
        String locId = location.getProperties().get(PROPERTY_ID, location.getName(), String.class)
                .toLowerCase(Locale.ENGLISH);
        String locType = location.getName();
        SaveablePolygon locPolygon = transformTiledPolygon(gameMap, getPolygonFromMapObject(location));
        GameLocation newLocation = loadTraps ? new TrapLocation(locId, locType, locPolygon,
                Boolean.valueOf(location.getProperties().get(PROPERTY_DETECTED, "false", String.class)),
                Boolean.valueOf(location.getProperties().get(PROPERTY_DISARMED, "false", String.class)))
                : new GameLocation(locId, locType, locPolygon);
        newLocation.setMap(gameMap);
        newLocation.loadFromXML(Gdx.files.internal(Configuration.getFolderLocations() + locType + ".xml"));
    }

    for (GameObject go : gameMap.gameObjects) {
        if (go instanceof GameCharacter) {
            ((GameCharacter) go).calculateCurrentLocations();
        }
    }
}
项目:fabulae    文件:GameMapLoader.java   
private void loadTransitions() {
    MapLayer locationsLayer = map.getLayers().get(LAYER_TRANSITIONS);
    if (locationsLayer == null) {
        return;
    }
    Array<Transition> transitions = new Array<Transition>();
    MapObjects locations = locationsLayer.getObjects();
    for (MapObject location : locations) {
        MapObject mapObject = (MapObject) location;
        String[] coords = ((String) mapObject.getProperties().get(PROPERTY_TARGET)).split(",");
        Tile target = new Tile(Integer.parseInt(coords[0].trim()), Integer.parseInt(coords[1].trim()));

        Polygon polygon = getPolygonFromMapObject(mapObject);
        Transition newTransition = new Transition(gameMap, mapObject.getName(), target.getX(), target.getY(),
                transformTiledPolygon(gameMap, polygon));
        transitions.add(newTransition);
    }
    buildTransitionTiles(transitions);
}
项目:fabulae    文件:GameMapLoader.java   
private Vector2 getPositionFromMapObject(MapObject mapObject) {
    if (mapObject instanceof PolygonMapObject) {
        Polygon polygon = ((PolygonMapObject) mapObject).getPolygon();
        return new Vector2(polygon.getX(), polygon.getY());
    } else if (mapObject instanceof RectangleMapObject) {
        Rectangle rectangle = ((RectangleMapObject) mapObject).getRectangle();
        return new Vector2(rectangle.getX(), rectangle.getY());
    } else if (mapObject instanceof EllipseMapObject) {
        Ellipse ellipse = ((EllipseMapObject) mapObject).getEllipse();
        return new Vector2(ellipse.x, ellipse.y);
    } else if (mapObject instanceof CircleMapObject) {
        Circle circle = ((CircleMapObject) mapObject).getCircle();
        return new Vector2(circle.x, circle.y);
    }
    throw new GdxRuntimeException("Only Polygons, Rectangles, Ellipses and Circles are supported!");
}
项目:Mario-Libgdx    文件:TmxMap.java   
private void initMapObjects() {

    items = new ArrayList<AbstractItem>();
    enemies = new ArrayList<AbstractEnemy>();
    sfxSprites = new ArrayList<AbstractSfxSprite>();
    plateforms = new ArrayList<AbstractMetalPlateform>();

    MapObjects objects = objectsLayer.getObjects();
    for (MapObject mapObject : objects) {

        MapProperties objectProperty = mapObject.getProperties();                                   
        if (objectProperty.get("type").toString().equals("mario")) {
            mario = new Mario(mapObject);
        }
        initEnemies(mapObject, objectProperty);
        initItems(mapObject, objectProperty);
        initSfxSprites(mapObject, objectProperty);
    }
}
项目:Mario-Libgdx    文件:TmxMap.java   
private void initEnemies(MapObject mapObject, MapProperties objectProperty) {
    if (objectProperty.get("type").toString().equals("piranha")) {              
        enemies.add(new PiranhaPlant(mapObject, mario));
    }
    if (objectProperty.get("type").toString().equals("goomba")) {               
        enemies.add(new Goomba(mapObject, worldType));
    }
    if (objectProperty.get("type").toString().equals("koopa")) {                
        enemies.add(new Koopa(mapObject));
    }           
    if (objectProperty.get("type").toString().equals("redKoopa")) {             
        enemies.add(new RedKoopa(mapObject));
    }
    if (objectProperty.get("type").toString().equals("castleFirebar")) {
        enemies.add(new CastleFirebar(mapObject));      
    }           
    if (objectProperty.get("type").toString().equals("bowser")) {               
        enemies.add(new Bowser(mapObject));
    }
}
项目:Mario-Libgdx    文件:AbstractTileObjectSfx.java   
public AbstractTileObjectSfx(MapObject mapObject, Vector2 offset) {

    super((Float) mapObject.getProperties().get("x")/32, (float)(((Float) mapObject.getProperties().get("y")) /32));

    this.offset.x = offset.x;
    this.offset.y = offset.y;

    float spriteWidth = (Float) mapObject.getProperties().get("width")/32;
    float spriteHeight = (Float) mapObject.getProperties().get("height")/32;

    setSize(spriteWidth - offset.x * 2, spriteHeight - offset.y);
    setRenderingSize(spriteWidth, spriteHeight);        
    setY(getY()+getHeight());
    bounds=new Rectangle(getX() + offset.x, getY(), getWidth(), getHeight());

    String xAliveString = (String) mapObject.getProperties().get("xAlive");
    xAlive = xAliveString!=null ? Float.parseFloat(xAliveString) / 32 : getX() - 16 ;       
}
项目:Mario-Libgdx    文件:AbstractTileObjectEnemy.java   
public AbstractTileObjectEnemy(MapObject mapObject, Vector2 offset) {

    super((Float) mapObject.getProperties().get("x")/32, (float)(((Float) mapObject.getProperties().get("y")) /32));

    this.offset.x = offset.x;
    this.offset.y = offset.y;

    float spriteWidth = (Float) mapObject.getProperties().get("width")/32;
    float spriteHeight = (Float) mapObject.getProperties().get("height")/32;

    setSize(spriteWidth - offset.x * 2, spriteHeight - offset.y);
    setRenderingSize(spriteWidth, spriteHeight);                
    setY(getY()+getHeight());
    bounds=new Rectangle(getX() + offset.x, getY(), getWidth(), getHeight());

    String xAliveString = (String) mapObject.getProperties().get("xAlive");
    xAlive = xAliveString!=null ? Float.parseFloat(xAliveString) / 32 : getX() - 16 ;       
}
项目:Mario-Libgdx    文件:AbstractTileObjectSprite.java   
public AbstractTileObjectSprite(MapObject mapObject, Vector2 offset) {

    super((Float) mapObject.getProperties().get("x")/32, (float)(((Float) mapObject.getProperties().get("y")) /32));

    this.offset.x = offset.x;
    this.offset.y = offset.y;

    float spriteWidth = (Float) mapObject.getProperties().get("width")/32;
    float spriteHeight = (Float) mapObject.getProperties().get("height")/32;

    setSize(spriteWidth - offset.x * 2, spriteHeight - offset.y);
    setRenderingSize(spriteWidth, spriteHeight);        
    setY(getY()+getHeight());
    bounds=new Rectangle(getX() + offset.x, getY(), getWidth(), getHeight());

    String xAliveString = (String) mapObject.getProperties().get("xAlive");
    xAlive = xAliveString!=null ? Float.parseFloat(xAliveString) / 32 : getX() - 16 ;       
}
项目:Mario-Libgdx    文件:AbstractTileObjectItem.java   
public AbstractTileObjectItem(MapObject mapObject, Vector2 offset) {

    super((Float) mapObject.getProperties().get("x")/32, (float)(((Float) mapObject.getProperties().get("y")) /32));

    this.offset.x = offset.x;
    this.offset.y = offset.y;

    float spriteWidth = (Float) mapObject.getProperties().get("width")/32;
    float spriteHeight = (Float) mapObject.getProperties().get("height")/32;

    setSize(spriteWidth - offset.x * 2, spriteHeight - offset.y);
    setRenderingSize(spriteWidth, spriteHeight);        
    setY(getY()+getHeight());
    bounds=new Rectangle(getX() + offset.x, getY(), getWidth(), getHeight());

    String xAliveString = (String) mapObject.getProperties().get("xAlive");
    xAlive = xAliveString!=null ? Float.parseFloat(xAliveString) / 32 : getX() - 16 ;           
}
项目:Mario-Libgdx    文件:CastleFirebar.java   
public CastleFirebar(MapObject mapObject) {
    super(mapObject, new Vector2());        
    setRenderingSize(3, 0.5f);
    setOrigin(0, 0.25f);
    bounds=new Rectangle(getX() + offset.x, getY(), getWidth(), getHeight());
    polygon = new Polygon(new float[]{getX() + offset.x,getY(),
            getX() + offset.x, getY()+getHeight()-offset.y, 
            getX() + offset.x + getWidth(), getY()+getHeight()-offset.y,
            getX() + offset.x + getWidth(), getY()
            });     
    polygon.setOrigin(getX() + offset.x, getY() + 0.25f);
    moveable = false;
    collidableWithTilemap = false;
    gravitating = false;
    killableByPlayer = false;
    killableByFireball = false;
    explodeFireball = false;

    float rotation = Float.parseFloat((String)mapObject.getProperties().get("angle"));      
    rotateBy(rotation);             
    polygon.setRotation(getRotation());
}
项目:Mario-Libgdx    文件:AbstractKoopa.java   
public AbstractKoopa(MapObject mapObject) {

    super(mapObject, new Vector2(0.2f, 0.1f));              

    setSize(1 - offset.x * 2, 1 - offset.y);
    bounds = new Rectangle(getX() + offset.x, getY(), getWidth(), getHeight()); 

    String sState = (String)mapObject.getProperties().get("state");
    if ("flying".equals(sState)) {
        collidableWithTilemap = false;
        gravitating = false;
        onFloor = false;
        currentAnimation = flyAnimation;
        state = SpriteMoveEnum.FLYING;
        direction = DirectionEnum.DOWN;     
        DECCELERATION_STEP = STEP_NUMBER/2 + 0.01f;
        acceleration.y = direction==DirectionEnum.UP ? ACCELERATION_MIN : -ACCELERATION_MIN;        
    } else {            
        currentAnimation = walkLeftAnimation;
        acceleration.x = -1.9f;
        acceleration.y = 0;
        onFloor = true;         
    }                                       

}
项目:Mario-Libgdx    文件:Bowser.java   
public Bowser(MapObject mapObject) {

        super(mapObject, new Vector2(0.2f, 0.1f));

        killableByPlayer = false;
        killableByFireball = true;
        deletableOutScreenRight = false;
        currentAnimation = walkAnimation;
        GRAVITY_COEF = 0.002f;

        acceleration.x = 1f;
        xInitial = getX();
        yInitial = getY();
        xTarget = xInitial;

        setState(SpriteMoveEnum.WALKING);

        tilemapCollisionHandler = new BowserTilemapCollisionHandler();      
    }
项目:Entitas-Java    文件:Box2DMapObjectParser.java   
private void createModelObject(World world, MapObject object) {
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.hero))
        box2dObjectFactory.createEntity(GRUPO.HERO, object);
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.movingPlatform))
        box2dObjectFactory.createEntity(GRUPO.MOVING_PLATFORM, object);
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.water))
        box2dObjectFactory.createEntity(GRUPO.FLUID, object);
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.enemy))
        box2dObjectFactory.createEntity(GRUPO.ENEMY, object);
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.item))
        box2dObjectFactory.createEntity(GRUPO.ITEMS, object);
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.millObject))
        box2dObjectFactory.createEntity(GRUPO.MILL, object);
    if (object.getProperties().get(aliases.typeModelObject).equals(aliases.checkPointObject))
        box2dObjectFactory.createEntity(GRUPO.CHECKPOINT, object);

}
项目:AI_TestBed_v3    文件:Level.java   
public void loadLevelObjects() {
    MapLayer mapLayerMission = getMap().getLayers().get(LAYER_MISSIONOBJECTS);

    MapObjects objects = mapLayerMission.getObjects();

    for (int i = 0; i < objects.getCount(); i++) {
        MapObject mapObj = objects.get(i);

        SpawnableBase base = EntityFactory.getEntity(mapObj.getName());
        if (base != null) {
            base.prepareFromMap(getLevelID(), mapObj);
        }
    }

    Logger.dbg("map objects loaded!");
}
项目:OdysseeDesMaths    文件:OrthogonalTiledMapRendererWithKoffee.java   
public void render(){
    beginRender();
    int layerCourant = 0;
    for(MapLayer layer : map.getLayers()){
        if(layer instanceof TiledMapTileLayer){
            renderTileLayer((TiledMapTileLayer)layer);
            layerCourant++;
            if(layerCourant==numberOfSpriteLayer){//if we are in the layer for the Sprite
                //just draw it up!!!!

                for(Sprite dropOfKoffee : superStrongKoffee){
                    System.out.println("Fuck OFFF!!!!");
                    dropOfKoffee.draw(this.batch);
                }
            }
        }else{
            for(MapObject wtfIsThisObject : layer.getObjects()){
                renderObject(wtfIsThisObject);
            }
        }
    }
    endRender();
}
项目:libgdx_mario    文件:InteractiveTileObject.java   
public InteractiveTileObject(PlayScreen screen, MapObject object) {
    this.screen = screen;
    this.world = screen.getWorld();
    this.map = screen.getMap();
    this.object = object;
    this.bounds = ((RectangleMapObject) object).getRectangle();

    BodyDef bdef = new BodyDef();
    FixtureDef fdef = new FixtureDef();
    PolygonShape shape = new PolygonShape();

    bdef.type = BodyDef.BodyType.StaticBody;
    bdef.position.set((bounds.getX() + bounds.getWidth() / 2) / MarioBros.PPM, (bounds.getY() + bounds.getHeight() / 2) / MarioBros.PPM);

    body = world.createBody(bdef);

    shape.setAsBox(bounds.getWidth() / 2 / MarioBros.PPM, bounds.getHeight() / 2 / MarioBros.PPM);
    fdef.shape = shape;
    fixture = body.createFixture(fdef);
}
项目:libgdx    文件:LevelManager.java   
/**
 * Carga los enemigos del nivel actual
 */
private static void loadEnemies() {

    Enemy enemy = null;

    // Carga los objetos m�viles del nivel actual
    for (MapObject object : LevelManager.map.getLayers().get("objects").getObjects()) {

        if (object instanceof RectangleMapObject) {
            RectangleMapObject rectangleObject = (RectangleMapObject) object;
            if (rectangleObject.getProperties().containsKey(TiledMapManager.ENEMY)) {
                Rectangle rect = rectangleObject.getRectangle();

                enemy = new Enemy();
                enemy.position.set(rect.x, rect.y);
                LevelManager.enemies.add(enemy);
            }
        }
    }
}
项目:libgdx    文件:LevelManager.java   
/**
 * Carga las plataformas m�viles de la pantalla actual
 */
public static void loadPlatforms() {

    Platform platform = null;

    // Carga los objetos m�viles del nivel actual
    for (MapObject object : LevelManager.map.getLayers().get("objects").getObjects()) {

        if (object instanceof RectangleMapObject) {
            RectangleMapObject rectangleObject = (RectangleMapObject) object;
            if (rectangleObject.getProperties().containsKey(TiledMapManager.MOBILE)) {
                Rectangle rect = rectangleObject.getRectangle();

                Direction direction = null;
                if (Boolean.valueOf((String) rectangleObject.getProperties().get("right_direction")))
                    direction = Direction.RIGHT;
                else
                    direction = Direction.LEFT;

                platform = new Platform(rect.x, rect.y, TiledMapManager.PLATFORM_WIDTH, TiledMapManager.PLATFORM_HEIGHT, 
                                        Integer.valueOf((String) rectangleObject.getProperties().get("offset")), direction);
                LevelManager.platforms.add(platform);
            }
        }
    }
}
项目:Simple-Isometric-Game    文件:MapProcessor.java   
public static void createCoins(Map map, MapLayer layer, Box2DWorld world) {

        Matrix4 transformMat4 = getTransformationMatrix(map);
        Vector3 coinPos = new Vector3();

        for(MapObject object : layer.getObjects()) {
            if(object instanceof RectangleMapObject) {
                RectangleMapObject rectangleObj = (RectangleMapObject)object;

                // Get coin position from map object and transform it by transformation matrix
                coinPos.set(rectangleObj.getRectangle().getX() + rectangleObj.getRectangle().width / 2,
                        rectangleObj.getRectangle().getY() + rectangleObj.getRectangle().height / 2, 0);
                coinPos.mul(transformMat4);

                // Create new Coin
                Coin newCoin = new Coin(coinPos.x, coinPos.y, world);

                // Add Coin entity to EntityManager
                map.getEntMan().addCoin(newCoin);

            }
        }
    }
项目:Simple-Isometric-Game    文件:MapProcessor.java   
public static Vector2 getPlayerPosition(Map map, MapLayer layer) {
    Vector2 playerPos = new Vector2(0,0);

    for(MapObject object : layer.getObjects()) {
        if(object instanceof EllipseMapObject) {
            EllipseMapObject mapObject = (EllipseMapObject)object;
            Vector3 tempVec3 = new Vector3();
            tempVec3.set(mapObject.getEllipse().x + mapObject.getEllipse().width / 2,
                    mapObject.getEllipse().y + mapObject.getEllipse().height / 2, 0);
            tempVec3.mul(getTransformationMatrix(map));

            playerPos.set(tempVec3.x, tempVec3.y);
        }
    }

    return playerPos;
}
项目:mario-game    文件:ParallaxLayer.java   
/**
 * Load the objects from the tmx file, convert them into textures and put them on the layer.
 */
private void loadObjects() {
    //TODO Use a spritesheet for the background objects
    Map map = world.getMap();
    Iterator<MapObject> it = map.getLayers().get(layer_name).getObjects().iterator();
    while(it.hasNext()) {
        MapObject obj = it.next();
        String file = "data/backgrounds/" + (String) obj.getProperties().get("src");
        layer_objects.add(obj);
        if(!layer_textures.containsKey(file)) {
            Texture texture = new Texture(file);
            texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
            layer_textures.put(file, texture);
        }
    }
}
项目:mario-game    文件:World.java   
private Array<Goomba> generateEnemies() {
    Array<Goomba> goombas = new Array<Goomba>();
    MapLayer layer = map.getLayers().get("objects");
    MapObjects objects = layer.getObjects();
    Iterator<MapObject> objectIt = objects.iterator();
    while(objectIt.hasNext()) {
        MapObject obj = objectIt.next();
        String type = (String) obj.getProperties().get("type");
        if(type != null) {
            float x = (Float) obj.getProperties().get("x");
            float y = (Float) obj.getProperties().get("y");
            if(type.equals("goomba")) {
                Goomba goomba = new Goomba(this, x * (1/16f), y* (1/16f));
                goombas.add(goomba);
                stage.addActor(goomba);
            }
        }
    }
    return goombas;
}
项目:mario-game    文件:World.java   
/**
 * Setup the flag at the end of the level
 * @param layer Tmx map layer with the object named 'flag';
 */
private void generateFlag(MapLayer layer) {
    MapObject obj = layer.getObjects().get("flag");
    float x = (Float) obj.getProperties().get("x") * World.scale;
    float y = (Float) obj.getProperties().get("y") * World.scale;
    float width = Float.valueOf((String) obj.getProperties().get("width"));
    float height = Float.valueOf((String) obj.getProperties().get("height"));

    // The object in the map named 'flag_end' determines the position Mario walks to after the flag
    MapObject flag_end = layer.getObjects().get("flag_end");
    float flag_end_x = (Float) flag_end.getProperties().get("x") * World.scale; 
    float flag_end_y = (Float) flag_end.getProperties().get("y") * World.scale; 

    flag = new Flag(x, y, width, height, flag_end_x, flag_end_y);
    stage.addActor(flag);
}