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


C++ TMXMapInfo::getTileSize方法代码示例

本文整理汇总了C++中TMXMapInfo::getTileSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TMXMapInfo::getTileSize方法的具体用法?C++ TMXMapInfo::getTileSize怎么用?C++ TMXMapInfo::getTileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TMXMapInfo的用法示例。


在下文中一共展示了TMXMapInfo::getTileSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initWithTMXFile

bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile, bool isHalf)
{
    CCASSERT(tmxFile.size()>0, "FastTMXTiledMap: tmx file should not be empty");
    
    setContentSize(Size::ZERO);

    TMXMapInfo *mapInfo = TMXMapInfo::create(tmxFile);

    if (! mapInfo)
    {
        return false;
    }
    CCASSERT( !mapInfo->getTilesets().empty(), "FastTMXTiledMap: Map not found. Please check the filename.");
    
    if (isHalf) {
        Size size = mapInfo->getTileSize();
        mapInfo->setTileSize(Size(size.width/2, size.height/2));
        Vector<TMXTilesetInfo*> vec = mapInfo->getTilesets();
        for (int i=0; i<vec.size(); i++) {
            TMXTilesetInfo* tilesetInfo = vec.at(i);
            tilesetInfo->_tileSize.width /= 2;
            tilesetInfo->_tileSize.height /= 2;
            tilesetInfo->_imageSize.width /= 2;
            tilesetInfo->_imageSize.height /= 2;
        }
    }
    
    buildWithMapInfo(mapInfo);

    return true;
}
开发者ID:mixiancheng,项目名称:selfWork,代码行数:31,代码来源:CCFastTMXTiledMap.cpp

示例2: startElement


//.........这里部分代码省略.........
        }
    }
    else if (elementName == "layer")
    {
        TMXLayerInfo *layer = new (std::nothrow) TMXLayerInfo();
        layer->_name = attributeDict["name"].asString();

        Size s;
        s.width = attributeDict["width"].asFloat();
        s.height = attributeDict["height"].asFloat();
        layer->_layerSize = s;

        Value& visibleValue = attributeDict["visible"];
        layer->_visible = visibleValue.isNull() ? true : visibleValue.asBool();

        Value& opacityValue = attributeDict["opacity"];
        layer->_opacity = opacityValue.isNull() ? 255 : (unsigned char)(255.0f * opacityValue.asFloat());

        float x = attributeDict["x"].asFloat();
        float y = attributeDict["y"].asFloat();
        layer->_offset.set(x, y);

        tmxMapInfo->getLayers().pushBack(layer);
        layer->release();

        // The parent element is now "layer"
        tmxMapInfo->setParentElement(TMXPropertyLayer);
    } 
    else if (elementName == "objectgroup")
    {
        TMXObjectGroup *objectGroup = new (std::nothrow) TMXObjectGroup();
        objectGroup->setGroupName(attributeDict["name"].asString());
        Vec2 positionOffset;
        positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width;
        positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height;
        objectGroup->setPositionOffset(positionOffset);

        tmxMapInfo->getObjectGroups().pushBack(objectGroup);
        objectGroup->release();

        // The parent element is now "objectgroup"
        tmxMapInfo->setParentElement(TMXPropertyObjectGroup);
    }
    else if (elementName == "image")
    {
        TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back();

        // build full path
        std::string imagename = attributeDict["source"].asString();
        tileset->_originSourceImage = imagename;

        if (_TMXFileName.find_last_of("/") != string::npos)
        {
            string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);
            tileset->_sourceImage = dir + imagename;
        }
        else 
        {
            tileset->_sourceImage = _resources + (_resources.size() ? "/" : "") + imagename;
        }
    } 
    else if (elementName == "data")
    {
        std::string encoding = attributeDict["encoding"].asString();
        std::string compression = attributeDict["compression"].asString();
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:66,代码来源:CCTMXXMLParser.cpp


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