本文整理汇总了C++中TileSet::GetTileTextureCoords方法的典型用法代码示例。如果您正苦于以下问题:C++ TileSet::GetTileTextureCoords方法的具体用法?C++ TileSet::GetTileTextureCoords怎么用?C++ TileSet::GetTileTextureCoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileSet
的用法示例。
在下文中一共展示了TileSet::GetTileTextureCoords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateVertexArray
sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
{
sf::VertexArray vertexArray(sf::Quads);
int tileWidth = tileSet.tileSize.x;
int tileHeight = tileSet.tileSize.y;
if(tileSet.IsDirty())
return vertexArray;
for(int layer = 0; layer < 3; layer++)
{
for(int col = 0; col < tileMap.GetColumnsCount(); col++)
{
for(int row = 0; row < tileMap.GetRowsCount(); row++)
{
TileTextureCoords coords;
if(tileMap.GetTile(layer, col, row) != -1)
{
coords = tileSet.GetTileTextureCoords(tileMap.GetTile(layer, col, row));
}
else
{
coords = tileSet.GetTileTextureCoords(0);
}
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, row * tileHeight), coords.topLeft);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, (row + 1) * tileHeight), coords.bottomLeft);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, (row + 1) * tileHeight), coords.bottomRight);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, row * tileHeight), coords.topRight);
if(tileMap.GetTile(layer, col, row) == -1)
vertex.color.a = 0;
vertexArray.append(vertex);
}
}
}
}
return vertexArray;
}
示例2: UpdateVertexArray
void UpdateVertexArray(sf::VertexArray &vertexArray, int layer, int col, int row, TileSet &tileSet, TileMap &tileMap)
{
if(tileSet.IsDirty())
return;
const int vertexPos = 4 * (layer * tileMap.GetColumnsCount() * tileMap.GetRowsCount() + col * tileMap.GetRowsCount() + row);
TileTextureCoords newCoords = tileMap.GetTile(layer, col, row) != -1 ? tileSet.GetTileTextureCoords(tileMap.GetTile(layer, col, row)) : tileSet.GetTileTextureCoords(0);
vertexArray[vertexPos].texCoords = newCoords.topLeft;
vertexArray[vertexPos + 1].texCoords = newCoords.bottomLeft;
vertexArray[vertexPos + 2].texCoords = newCoords.bottomRight;
vertexArray[vertexPos + 3].texCoords = newCoords.topRight;
for(int i = 0; i < 4; i++)
{
if(tileMap.GetTile(layer, col, row) == -1)
{
vertexArray[vertexPos + i].color.a = 0;
}
else
{
vertexArray[vertexPos + i].color.a = 255;
}
}
}