Beispiel #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);
    }
  }
Beispiel #2
0
 public void setCustomPortal(World world, float x, float y) {
   if (customsPortalBody != null) {
     world.destroyBody(customsPortalBody);
   }
   final Vector2 portalPos = new Vector2(x - offset.x, y - offset.y);
   portals.put("portal_custom", portalPos);
   customsPortalBody = addPortalBody(world, "portal_custom", portalPos);
 }
Beispiel #3
0
 public Vector2 getPortal(String portal) {
   return portals.get(portal).cpy();
 }
Beispiel #4
0
 public boolean hasPortal(String name) {
   return portals.containsKey(name);
 }