SFML community forums

Help => General => Topic started by: Remi749 on November 26, 2017, 04:53:54 pm

Title: Parsing "Collection of Images" with json doesn't work
Post by: Remi749 on November 26, 2017, 04:53:54 pm
Hi, so I have a Tiled map, I have a "based on a tileset image" tileset, and a "Collection of Images" tileset with a few images of different sizes inside.

Everything works fine, but not for the "Collection of Images" tileset and parsing this with json to our game.

Here is the layer loader from json to cpp. It loads the layer and it works fine, if I add something to the map from "Collection of Images" tileset, it is ignored. I can still collide with it, but it isn't shown.

void MapMaker::loadLayer(Json::Value &layer, std::list<Object *> &objects, TileSize tileSize) {

    MapLayer *tmp = new MapLayer(tileSize);

    tmp->width = layer["width"].asInt();
    tmp->height = layer["height"].asInt();

    memset(tmp->tileMap, 0, sizeof(tmp->tileMap));

    for(size_t i = 0; i < layer["data"].size(); ++i)
        tmp->tileMap[i] = layer["data"][(int)i].asInt();

    tmp->isCollisionLayer = layer["properties"]["Collision"].asBool();

    objects.push_back(tmp);

}

The crates in the images are from the "Collection of Images" tileset
(https://image.prntscr.com/image/sVwQdIanR0W0QwQANqcHyw.png)

but in-game these are gone, but the player can still collide with them...
(https://image.prntscr.com/image/V8qfUoj3SUW2vfwEyYjqAQ.png)

I bet there is some code missing. if anyone can help that would be greatly appreciated.

I have attached the json map file if needed.
Title: Re: Parsing "Collection of Images" with json doesn't work
Post by: Kerachi on November 26, 2017, 10:31:29 pm
If you allow me I have some question about this.

Code: [Select]
imageName = layer["tiles"]["1"]["image"];
imageWidth = layer["tiles"]["1"]["imagewidth"];
imageHeight = layer["tiles"]["1"]["imageheight"];
//and other attributions...
//after that, you could load the image(s)...