예제 #1
0
  public void applyPhysics(World world) {
    final Iterator<MapLayer> layerIterator = tiledMap.getLayers().iterator();
    while (layerIterator.hasNext()) {
      final MapLayer mapLayer = layerIterator.next();
      if (mapLayer instanceof TiledMapTileLayer) {
        final TiledMapTileLayer tiledLayer = (TiledMapTileLayer) mapLayer;
        final int width = tiledLayer.getWidth();
        final int height = tiledLayer.getHeight();
        for (int y = 0; y < height; y++) {
          for (int x = 0; x < width; x++) {
            final TiledMapTileLayer.Cell cell = tiledLayer.getCell(x, y);
            if (cell == null) {
              continue;
            }
            final boolean dirt = cell.getTile().getProperties().containsKey("dirt");
            final boolean noWall = cell.getTile().getProperties().containsKey("nowall");
            if (!noWall) {
              addBody(world, x + offset.x, y + offset.y, dirt);
            }
          }
        }
      }
    }

    for (String portalName : portals.keySet()) {
      final Vector2 portalPosition = portals.get(portalName);
      addPortalBody(world, portalName, portalPosition);
    }

    final Vector2 finish = getTriggerPoint("finish");
    if (finish != null) {
      addFinish(world, finish);
    }
  }
예제 #2
0
 public Vector2 getPortal(String portal) {
   return portals.get(portal).cpy();
 }