The problem is that when a modify a vertexarray the modifications are in the bottom layer and the object that I want to refresh remains in the top layer.
This is a code of an animation, it works but if I put it in the same position of another quad it will be covered by the static object that i want to modify.
for (auto &itr1 : tiled_map_animations)
{
for (auto &itr2 : ids)
{
if (tmx_info.maps[2][itr2]+ 4 == itr1.first)
{
sf::Vertex* quad = &map_layers[2].entity_vertex[itr1.first * 4];
float x = itr1.second[current_anim].left;
float y = itr1.second[current_anim].top;
float w = itr1.second[current_anim].width;
float h = itr1.second[current_anim].height;
float pos_x = (itr2 % map_width) * tile_width;
float pos_y = (itr2 / map_width) * tile_height;
quad[0].texCoords = sf::Vector2f(x, y);
quad[1].texCoords = sf::Vector2f(x + w, y);
quad[2].texCoords = sf::Vector2f(x + w, y + h);
quad[3].texCoords = sf::Vector2f(x, y + h);
quad[0].position = sf::Vector2f(pos_x, pos_y);
quad[1].position = sf::Vector2f(pos_x + w, pos_y);
quad[2].position = sf::Vector2f(pos_x + w, pos_y + h);
quad[3].position = sf::Vector2f(pos_x, pos_y + h);
}
}
}