Can we add objects in ObjectGroup to our layer or are they simply used from coordinate calculations

Can we add objects in ObjectGroup to our layer or are they simply used from coordinate calculations
0.0 0

#1

I am attempting to add this tiled map to my project. I noticed that if I have a layer in the tiled file I can simply do this

        cocos2d::TMXTiledMap* tileMap;
 	tileMap = cocos2d::TMXTiledMap::create("sandbox.tmx");
 	tileMap->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
	this->addChild(tileMap);

Now I have this tiled file that came with the tiled software. The tiled file is located here.
As you can see this tiled file does not have any layers init and all the content in the file are basically objects inside object groups.I know we can iterate through the object collection using the code. However from the file you can see that the object group “ground” has multiple objects in it, I would like to display those objects.

TMXTiledMap *tileMap = TMXTiledMap::create("sandbox.tmx");
this->addChild(tileMap, 20);

auto group = tileMap->getObjectGroup("ground");
auto& objects = group->getObjects();

Value objectsVal = Value(objects);
log("%s", objectsVal.getDescription().c_str());

for (auto& obj : objects)
{
    ValueMap& dict = obj.asValueMap();

    float x = dict["x"].asFloat();
    float y = dict["y"].asFloat();
    float width = dict["width"].asFloat();
    float height = dict["height"].asFloat();
    
    // Add sprites here manually
    ??? How do I add this object to the layer. 
}

My question is how do I add the objects in the ground object group to my layer ? Is that possible or will I have to copy them to my layer first ?


Tiled map not being displayed in a new hello world project