本文整理汇总了C++中TMXLayer::getOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ TMXLayer::getOpacity方法的具体用法?C++ TMXLayer::getOpacity怎么用?C++ TMXLayer::getOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMXLayer
的用法示例。
在下文中一共展示了TMXLayer::getOpacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeSoloTileset
void TMXSceneEncoder::writeSoloTileset(const TMXMap& map, const gameplay::TMXTileSet& tmxTileset, const TMXLayer& tileset, std::ofstream& file, unsigned int resultOnlyForTileset)
{
WRITE_PROPERTY_BLOCK_START("tileset");
// Write tile path
WRITE_PROPERTY_BLOCK_VALUE("path", tmxTileset.getImagePath());
WRITE_PROPERTY_NEWLINE();
// Write tile size
//XXX if tile sizes are incorrect, make sure to update TMXLayer::getTileStart too
char buffer[BUFFER_SIZE];
snprintf(buffer, BUFFER_SIZE, "tileWidth = %u", tmxTileset.getMaxTileWidth());
WRITE_PROPERTY_DIRECT(buffer);
snprintf(buffer, BUFFER_SIZE, "tileHeight = %u", tmxTileset.getMaxTileHeight());
WRITE_PROPERTY_DIRECT(buffer);
// Write tileset size
snprintf(buffer, BUFFER_SIZE, "columns = %u", tileset.getWidth());
WRITE_PROPERTY_DIRECT(buffer);
snprintf(buffer, BUFFER_SIZE, "rows = %u", tileset.getHeight());
WRITE_PROPERTY_DIRECT(buffer);
WRITE_PROPERTY_NEWLINE();
// Write opacity
if (tileset.getOpacity() < 1.0f)
{
snprintf(buffer, BUFFER_SIZE, "opacity = %f", tileset.getOpacity());
WRITE_PROPERTY_DIRECT(buffer);
WRITE_PROPERTY_NEWLINE();
}
// Write tiles
unsigned int tilesetHeight = tileset.getHeight();
unsigned int tilesetWidth = tileset.getWidth();
for (unsigned int y = 0; y < tilesetHeight; y++)
{
bool tilesWritten = false;
for (unsigned int x = 0; x < tilesetWidth; x++)
{
Vector2 startPos = tileset.getTileStart(x, y, map, resultOnlyForTileset);
if (startPos.x < 0 || startPos.y < 0)
{
continue;
}
tilesWritten = true;
WRITE_PROPERTY_BLOCK_START("tile");
snprintf(buffer, BUFFER_SIZE, "cell = %u, %u", x, y);
WRITE_PROPERTY_DIRECT(buffer);
snprintf(buffer, BUFFER_SIZE, "source = %u, %u", static_cast<unsigned int>(startPos.x), static_cast<unsigned int>(startPos.y));
WRITE_PROPERTY_DIRECT(buffer);
WRITE_PROPERTY_BLOCK_END();
}
if (tilesWritten && ((y + 1) != tilesetHeight))
{
WRITE_PROPERTY_NEWLINE();
}
}
WRITE_PROPERTY_BLOCK_END();
}