当前位置: 首页>>代码示例>>C++>>正文


C++ TMXLayer::getOpacity方法代码示例

本文整理汇总了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();
}
开发者ID:03050903,项目名称:GamePlay,代码行数:61,代码来源:TMXSceneEncoder.cpp


注:本文中的TMXLayer::getOpacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。