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


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

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


在下文中一共展示了TMXMapInfo::getTilesets方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: initWithXML

bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath)
{
    setContentSize(Size::ZERO);

    TMXMapInfo *mapInfo = TMXMapInfo::createWithXML(tmxString, resourcePath);

    CCASSERT( !mapInfo->getTilesets().empty(), "FastTMXTiledMap: Map not found. Please check the filename.");
    buildWithMapInfo(mapInfo);

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

示例3: initWithTMXFile

bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
{
    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.");
    buildWithMapInfo(mapInfo);

    return true;
}
开发者ID:Ratel13,项目名称:WarriorQuest,代码行数:17,代码来源:CCFastTMXTiledMap.cpp

示例4: startElement


//.........这里部分代码省略.........
            }
            _recordFirstGID = false;
            
            tmxMapInfo->parseXMLFile(externalTilesetFilename);
        }
        else
        {
            TMXTilesetInfo *tileset = new (std::nothrow) TMXTilesetInfo();
            tileset->_name = attributeDict["name"].asString();
            
            if (_recordFirstGID)
            {
                // unset before, so this is tmx file.
                tileset->_firstGid = attributeDict["firstgid"].asInt();
                
                if (tileset->_firstGid < 0)
                {
                    tileset->_firstGid = 0;
                }
            }
            else
            {
                tileset->_firstGid = _currentFirstGID;
                _currentFirstGID = 0;
            }
            
            tileset->_spacing = attributeDict["spacing"].asInt();
            tileset->_margin = attributeDict["margin"].asInt();
            Size s;
            s.width = attributeDict["tilewidth"].asFloat();
            s.height = attributeDict["tileheight"].asFloat();
            tileset->_tileSize = s;

            tmxMapInfo->getTilesets().pushBack(tileset);
            tileset->release();
        }
    }
    else if (elementName == "tile")
    {
        if (tmxMapInfo->getParentElement() == TMXPropertyLayer)
        {
            TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
            Size layerSize = layer->_layerSize;
            uint32_t gid = static_cast<uint32_t>(attributeDict["gid"].asInt());
            int tilesAmount = layerSize.width*layerSize.height;
            
            if (_xmlTileIndex < tilesAmount)
            {
                layer->_tiles[_xmlTileIndex++] = gid;
            }
        }
        else
        {
            TMXTilesetInfo* info = tmxMapInfo->getTilesets().back();
            tmxMapInfo->setParentGID(info->_firstGid + attributeDict["id"].asInt());
            tmxMapInfo->getTileProperties()[tmxMapInfo->getParentGID()] = Value(ValueMap());
            tmxMapInfo->setParentElement(TMXPropertyTile);
        }
    }
    else if (elementName == "layer")
    {
        TMXLayerInfo *layer = new (std::nothrow) TMXLayerInfo();
        layer->_name = attributeDict["name"].asString();

        Size s;
        s.width = attributeDict["width"].asFloat();
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:67,代码来源:CCTMXXMLParser.cpp

示例5: init


//.........这里部分代码省略.........
					origin.y + visibleSize.height - label->getContentSize().height));
		// add the label as a child to this layer
		this->addChild(label, priority++);
		tiledmap = TMXTiledMap::create("stage1.tmx");
		mapinfo = TMXMapInfo::create("stage1.tmx");
	}else if(stage_no==2){
		_slushLimit=2;
		auto label = LabelTTF::create(GetUTF8FromSJIS("チャンスは2回のみだ"), "Arial", 24);
		// position the label on the center of the screen
		label->setPosition(Vec2(origin.x + visibleSize.width/2,
					origin.y + visibleSize.height - label->getContentSize().height));

		// add the label as a child to this layer
		this->addChild(label, priority++);

		tiledmap = TMXTiledMap::create("stage2.tmx");
		mapinfo = TMXMapInfo::create("stage2.tmx");
	}else if(stage_no==2){
		_slushLimit=3;
#ifdef _WINDOWS
		auto label = LabelTTF::create(GetUTF8FromSJIS("3回切ってくれたまえ"), "Arial", 24);
#else
		auto label = LabelTTF::create(GetUTF8FromSJIS("3回切ってくれたまえ"),"Arial",24);
#endif
		// position the label on the center of the screen
		label->setPosition(Vec2(origin.x + visibleSize.width/2,
					origin.y + visibleSize.height - label->getContentSize().height));

		// add the label as a child to this layer
		this->addChild(label, priority++);

		tiledmap = TMXTiledMap::create("stage3.tmx");
		mapinfo = TMXMapInfo::create("stage3.tmx");
	}else{
		_slushLimit=3;
		auto data = cocos2d::FileUtils::sharedFileUtils()->getStringFromFile("String.txt");
		
		auto label = LabelTTF::create(data.c_str()/*("3回ぶった斬れ!!")*/, "MS Pゴシック", 24);
    
		// position the label on the center of the screen
		label->setPosition(Vec2(origin.x + visibleSize.width/2,
					origin.y + visibleSize.height - label->getContentSize().height));

		// add the label as a child to this layer
		this->addChild(label, priority++);

		tiledmap = TMXTiledMap::create("stage4.tmx");
		mapinfo = TMXMapInfo::create("stage4.tmx");
	}
	
	auto soni=Sprite::create("soniko_t.png");
	soni->setScale(0.5);
	soni->setPosition(250,400);
	addChild(soni);


	Vector<TMXTilesetInfo*>& tileset = mapinfo->getTilesets();
	TMXTilesetInfo* ts= tileset.at(0);
	
	ObjectLayerParse(tiledmap->getObjectGroup("cuttable"),priority);
	ObjectLayerParse(tiledmap->getObjectGroup("scaffold"),priority);
  
	auto director = Director::getInstance();
	
	auto listener=EventListenerTouchOneByOne::create();
	listener->onTouchBegan=CC_CALLBACK_2(GamePlaying::onTouchBegan,this);
	listener->onTouchMoved=CC_CALLBACK_2(GamePlaying::onTouchMoved,this);
	listener->onTouchEnded=CC_CALLBACK_2(GamePlaying::onTouchEnded,this);

	getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener,this);

	Director::getInstance()->getTextureCache()->addImage("blade.png");

	auto qp=ParticleSystemQuad::create("hellfire.plist");
	qp->setPosition(300,0);
	addChild(qp,10);

	//auto streak = MotionStreak::create(0.3f,0.01f,30.f,Color3B::WHITE,"trail.png");
	//streak->setName("streak");
	//streak->setBlendFunc(BlendFunc::ALPHA_PREMULTIPLIED);
	//addChild(streak);

	//streak->setBlendFunc(b);
	//cocos2d::BlendFunc b;
	//b.dst=GL_ZERO;
	//b.src=GL_ONE_MINUS_DST_COLOR;
	//
	//auto s=Sprite::create();
	//s->setTextureRect(Rect(0,0,480,800));
	//s->setPosition(240,400);
	//s->setColor(Color3B::WHITE);
	//s->setBlendFunc(b);
	//s->setName("reverse");
	//s->setVisible(false);
	//addChild(s,65535);

	scheduleUpdate();

    return true;
}
开发者ID:boxerprogrammer,项目名称:BlobSlusher,代码行数:101,代码来源:GamePlayingScene.cpp


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