Hello all,
Another noob problem here. The vertex array based tile system uses this method to define texture coorinates for each tile:
map[current + 0].texCoords = sf::Vector2f((tx + 0) * size, (ty + 0) * size);
map[current + 1].texCoords = sf::Vector2f((tx + 0) * size, (ty + 1) * size);
map[current + 2].texCoords = sf::Vector2f((tx + 1) * size, (ty + 1) * size);
map[current + 3].texCoords = sf::Vector2f((tx + 1) * size, (ty + 0) * size);
(int tx and int ty are the x and y coordinates of the desired part of the texture, int size is the size of the tile).
The vertex array itself is defined like this:
sf::VertexArray map(sf::Quads, layer_width * layer_height * 4);
Now the problem with this is that I can't define an empty texture. If both tx and ty are 0, the first image of the tileset will be drawn. When I modified the texture coordinate routine to this:
map[current + 0].texCoords = sf::Vector2f(0, 0);
map[current + 1].texCoords = sf::Vector2f(0, 0);
map[current + 2].texCoords = sf::Vector2f(0, 0);
map[current + 3].texCoords = sf::Vector2f(0, 0);
the empty tiles were filled with the first pixel of the tileset image, resulting in a solid color.
How can I set up the texture coordinates to render the tile untextured/completely transparent/invisible?
EDIT: Forgot to mention that when the tile map is loaded from a tile, and the app starts processing the tile IDs, the normal coordinate setup routine is used (the first code snippet) if the tile ID is larger than zero, and if it's zero or less, the empty coordinate routine should be used to texture the current tile.