Rather than make the map objects themselves game entities, you could use them as spawn points. For example:
for(const auto& o : layer.objects)
m_items.push_back(std::make_unique<Collectable>(o.GetPosition()));
then for collision testing and destruction you don't even need to query the map:
for(auto& i : m_items)
{
if(i.contains(player.bounds))
i.setCollected(true);
}
m_items.erase(std::remove_if(m_items.begin(),
m_items.end(),
[](const Item::Ptr& p)->bool
{
return (p->Collected());
}), m_items.end());
how would I declare "m_items"? tmx::MapObject array? std::Vector<tmx::MapObject>?
thx in advance