Example #1
0
 public static void init() {
   allLoaded = true;
   TextureAtlas _atlasInstruction = manager.get("data/comic.atlas", TextureAtlas.class);
   COMIC = _atlasInstruction.findRegions("comic");
   METER = _atlasInstruction.findRegion("indicator");
   TextureAtlas _atlasInstruction2 = manager.get("data/comic2.atlas", TextureAtlas.class);
   COMIC2 = _atlasInstruction2.findRegions("comic");
   METER2 = _atlasInstruction2.findRegion("indicator");
 }
Example #2
0
  public static CustomLevel.LevelDef getGridDef() {
    TextureAtlas atlas = MainGame.assets.get("game.atlas", TextureAtlas.class);
    CustomLevel.LevelDef def = new CustomLevel.LevelDef();
    def.tX = 128;
    def.tY = 128;

    Array<TextureAtlas.AtlasRegion> regions = atlas.findRegions("map/grid");
    def.tiles = new TextureRegion[regions.size];
    for (int i = 0; i < regions.size; i++) {
      def.tiles[i] = regions.get(i);
    }

    def.width = 3072;
    def.height = 2048;
    def.seed = new Random();
    def.buildBoundraies(10);
    def.lights =
        new BaseLight[] {
          new DirectionalLight().set(0.6f, 0.6f, 0.6f, 0, 1, 0),
          new DirectionalLight().set(0.7f, 0.7f, 0.7f, 0, -1, 0),
          new DirectionalLight().set(0.1f, 0.1f, 0.1f, 0, 0, -1)
        };
    def.playerDef = MainGame.state.getPlayerDef();
    def.playerDef.position = new Vector2(def.width / 2, def.height / 2);
    return def;
  }
Example #3
0
  public static void init() {
    allLoaded = true;

    TextureAtlas _atlasDelhi = manager.get("data/delhi1.atlas", TextureAtlas.class);
    DelhiSky = _atlasDelhi.findRegion("sky");
    DelhiHouse = _atlasDelhi.findRegion("city");

    TextureAtlas _atlasBlock = manager.get("data/blocks1.atlas", TextureAtlas.class);
    Hypocrite = _atlasBlock.findRegions("redman");
    WARING = _atlasBlock.findRegions("no_entry");
    BARRICADE = _atlasBlock.findRegions("police");
    WATERGUN = _atlasBlock.findRegions("watergun");

    TextureAtlas _atlasCrowd = manager.get("data/crowd.atlas", TextureAtlas.class);
    CROWD = _atlasCrowd.findRegions("crowd");
    TextureAtlas _atlasCelebration = manager.get("data/levelover.atlas", TextureAtlas.class);
    CELEBRATION = _atlasCelebration.findRegion("congo");
  }
  protected void loadTileset(
      TiledMap map,
      Element element,
      FileHandle tmxFile,
      AtlasResolver resolver,
      AtlasTiledMapLoaderParameters parameter) {
    if (element.getName().equals("tileset")) {
      String name = element.get("name", null);
      int firstgid = element.getIntAttribute("firstgid", 1);
      int tilewidth = element.getIntAttribute("tilewidth", 0);
      int tileheight = element.getIntAttribute("tileheight", 0);
      int spacing = element.getIntAttribute("spacing", 0);
      int margin = element.getIntAttribute("margin", 0);
      String source = element.getAttribute("source", null);

      String imageSource = "";
      int imageWidth = 0, imageHeight = 0;

      FileHandle image = null;
      if (source != null) {
        FileHandle tsx = getRelativeFileHandle(tmxFile, source);
        try {
          element = xml.parse(tsx);
          name = element.get("name", null);
          tilewidth = element.getIntAttribute("tilewidth", 0);
          tileheight = element.getIntAttribute("tileheight", 0);
          spacing = element.getIntAttribute("spacing", 0);
          margin = element.getIntAttribute("margin", 0);
          imageSource = element.getChildByName("image").getAttribute("source");
          imageWidth = element.getChildByName("image").getIntAttribute("width", 0);
          imageHeight = element.getChildByName("image").getIntAttribute("height", 0);
        } catch (IOException e) {
          throw new GdxRuntimeException("Error parsing external tileset.");
        }
      } else {
        imageSource = element.getChildByName("image").getAttribute("source");
        imageWidth = element.getChildByName("image").getIntAttribute("width", 0);
        imageHeight = element.getChildByName("image").getIntAttribute("height", 0);
      }

      // get the TextureAtlas for this tileset
      TextureAtlas atlas = null;
      String regionsName = "";
      if (map.getProperties().containsKey("atlas")) {
        FileHandle atlasHandle =
            getRelativeFileHandle(tmxFile, map.getProperties().get("atlas", String.class));
        atlasHandle = resolve(atlasHandle.path());
        atlas = resolver.getAtlas(atlasHandle.path());
        regionsName = atlasHandle.nameWithoutExtension();

        if (parameter != null && parameter.forceTextureFilters) {
          for (Texture texture : atlas.getTextures()) {
            trackedTextures.add(texture);
          }
        }
      }

      TiledMapTileSet tileset = new TiledMapTileSet();
      MapProperties props = tileset.getProperties();
      tileset.setName(name);
      props.put("firstgid", firstgid);
      props.put("imagesource", imageSource);
      props.put("imagewidth", imageWidth);
      props.put("imageheight", imageHeight);
      props.put("tilewidth", tilewidth);
      props.put("tileheight", tileheight);
      props.put("margin", margin);
      props.put("spacing", spacing);

      Array<AtlasRegion> regions = atlas.findRegions(regionsName);
      for (AtlasRegion region : regions) {
        // handle unused tile ids
        if (region != null) {
          StaticTiledMapTile tile = new StaticTiledMapTile(region);

          if (!yUp) {
            region.flip(false, true);
          }

          int tileid = firstgid + region.index;
          tile.setId(tileid);
          tileset.putTile(tileid, tile);
        }
      }

      Array<Element> tileElements = element.getChildrenByName("tile");

      for (Element tileElement : tileElements) {
        int localtid = tileElement.getIntAttribute("id", 0);
        TiledMapTile tile = tileset.getTile(firstgid + localtid);
        if (tile != null) {
          String terrain = tileElement.getAttribute("terrain", null);
          if (terrain != null) {
            tile.getProperties().put("terrain", terrain);
          }
          String probability = tileElement.getAttribute("probability", null);
          if (probability != null) {
            tile.getProperties().put("probability", probability);
          }
          Element properties = tileElement.getChildByName("properties");
          if (properties != null) {
            loadProperties(tile.getProperties(), properties);
          }
        }
      }

      Element properties = element.getChildByName("properties");
      if (properties != null) {
        loadProperties(tileset.getProperties(), properties);
      }
      map.getTileSets().addTileSet(tileset);
    }
  }