I'm currently having issues with the TMX loader and setting object's visablity to false to have them not drawn.
if (handleEvent.type == sf::Event::EventType::KeyPressed && sf::Keyboard::isKeyPressed(sf::Keyboard::E))
for(auto layer = ml.GetLayers().begin(); layer != ml.GetLayers().end(); ++layer)
{
if(layer->name == "Interactables")
{
for(auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
{
if (object->Contains(sf::Vector2f(tankSprite.getPosition().x, tankSprite.getPosition().y)))
{
if (object->GetType() == "Computer")
{
for(auto object2 = layer->objects.begin(); object2 != layer->objects.end(); ++object2)
{
if (object2->GetType() == "Laser")
if (object2->GetName() == object->GetName())
{
object2->SetVisible(false);
object2->SetProperty("State", "Off");
}
}
}
}
}
}
}
That's how I am doing it but when I look at the map the object is still being drawn. I've checked to make sure the objects I want are not being set to visable when drawn with
for(auto layer = ml.GetLayers().begin(); layer != ml.GetLayers().end(); ++layer)
{
if(layer->name == "Interactables")
{
for(auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
{
if (object->Visible())
std::cout << "STILL THERE! " << object->GetType() << std::endl;
}
}
}
Sorry if this code is rather sloppy, I've been quickly writing it as a proof of concept for tmx loader. Any insight to what I am doing wrong and why the objects are still being drawn on the screen would be greatly appreciated.
Thanks,
MJBrune