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


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

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


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

示例1: initWithTMXFile

	bool CCTMXTiledMap::initWithTMXFile(const char *tmxFile)
	{
		CCAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi nil");
		
		setContentSize(CCSizeZero);

		CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithTMXFile(tmxFile);
    
        if (! mapInfo)
        {
            return false;
        }
		CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");

		m_tMapSize = mapInfo->getMapSize();
		m_tTileSize = mapInfo->getTileSize();
		m_nMapOrientation = mapInfo->getOrientation();
		setObjectGroups(mapInfo->getObjectGroups());
		setProperties(mapInfo->getProperties());
		CC_SAFE_RELEASE(m_pTileProperties);
		m_pTileProperties = mapInfo->getTileProperties();
		CC_SAFE_RETAIN(m_pTileProperties);

		int idx = 0;

		CCMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
		if (layers && layers->count()>0)
		{
            if (NULL == m_pTMXLayers)
            {
                m_pTMXLayers = new CCDictionary<std::string, CCTMXLayer*>();
                CCAssert(m_pTMXLayers, "Allocate memory failed!");
            }

			CCTMXLayerInfo *layerInfo = NULL;
			CCMutableArray<CCTMXLayerInfo*>::CCMutableArrayIterator it;
			for (it = layers->begin(); it != layers->end(); ++it)
			{
				layerInfo = *it;
				if (layerInfo && layerInfo->m_bVisible)
				{
					CCTMXLayer *child = parseLayer(layerInfo, mapInfo);
					addChild((CCNode*)child, idx, idx);

                    // record the CCTMXLayer object by it's name
                    std::string layerName = child->getLayerName();
                    m_pTMXLayers->setObject(child, layerName);

					// update content size with the max size
					CCSize childSize = child->getContentSize();
					CCSize currentSize = this->getContentSize();
					currentSize.width = MAX( currentSize.width, childSize.width );
					currentSize.height = MAX( currentSize.height, childSize.height );
					this->setContentSize(currentSize);

					idx++;
				}
			}
		}
		return true;
	}
开发者ID:MySure,项目名称:Test,代码行数:61,代码来源:CCTMXTiledMap.cpp

示例2: startElement


//.........这里部分代码省略.........
        s.width = (float)atof(valueForKey("width", attributeDict));
        s.height = (float)atof(valueForKey("height", attributeDict));
        layer->m_tLayerSize = s;

        std::string visible = valueForKey("visible", attributeDict);
        layer->m_bVisible = !(visible == "0");

        std::string opacity = valueForKey("opacity", attributeDict);
        if( opacity != "" )
        {
            layer->m_cOpacity = (unsigned char)(255 * atof(opacity.c_str()));
        }
        else
        {
            layer->m_cOpacity = 255;
        }

        float x = (float)atof(valueForKey("x", attributeDict));
        float y = (float)atof(valueForKey("y", attributeDict));
        layer->m_tOffset = ccp(x,y);

        pTMXMapInfo->getLayers()->addObject(layer);
        layer->release();

        // The parent element is now "layer"
        pTMXMapInfo->setParentElement(TMXPropertyLayer);

    } 
    else if(elementName == "objectgroup")
    {
        CCTMXObjectGroup *objectGroup = new CCTMXObjectGroup();
        objectGroup->setGroupName(valueForKey("name", attributeDict));
        CCPoint positionOffset;
        positionOffset.x = (float)atof(valueForKey("x", attributeDict)) * pTMXMapInfo->getTileSize().width;
        positionOffset.y = (float)atof(valueForKey("y", attributeDict)) * pTMXMapInfo->getTileSize().height;
        objectGroup->setPositionOffset(positionOffset);

        pTMXMapInfo->getObjectGroups()->addObject(objectGroup);
        objectGroup->release();

        // The parent element is now "objectgroup"
        pTMXMapInfo->setParentElement(TMXPropertyObjectGroup);

    }
    else if(elementName == "image")
    {
        CCTMXTilesetInfo* tileset = (CCTMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject();

        // build full path
        std::string imagename = valueForKey("source", attributeDict);
        if (m_sTMXFileName.length() == 0)
        {
            string pszFullPath = CCFileUtils::fullPathFromRelativePath(m_sResources.c_str());
            if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1)
            {
                pszFullPath.append("/");
            }

            tileset->m_sSourceImage = CCFileUtils::fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str()  );
        }
        else
        {
            tileset->m_sSourceImage = CCFileUtils::fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName());
        }
    } 
    else if(elementName == "data")
开发者ID:Aaron-Teng,项目名称:AnalyticX,代码行数:67,代码来源:CCTMXXMLParser.cpp


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