I made an Object Layer in tiled with afew spawn points.
I have been trying to use this code to iterate through the spawn points but it dosent seem to work.
if (type.find("enemy") != std::string::npos)
{
for (auto layer = ml->GetLayers().begin(); layer != ml->GetLayers().end(); ++layer)
{
if (layer->name == "spawns")
{
for (auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
{
std::unordered_map<std::string, Entity*>::const_iterator it = this->map.find(type);
while (it != this->map.end())
{
if (it->second->getPosition() != object->GetPosition())
{
e->setPosition(object->GetPosition());
return 1;
}
}
return 0;
}
break;
}
}
}
It wont go inside the second for-loop for some reason.
This is the object group located in the tmx file:
<objectgroup name="spawns">
<object id="18" name="spawn" x="390" y="225"/>
<object id="20" name="spawn" x="642" y="225"/>
<object id="21" name="spawn" x="390" y="515"/>
<object id="22" name="spawn" x="642" y="515"/>
</objectgroup>
I thought since the collision code that he showed in his Github wiki page was pretty similliar with what I was trying to do, I'd use it for getting the spawn locations aswell.
Link to the git :
https://github.com/fallahn/sfml-tmxloader