コード例 #1
0
ファイル: TileMapTest.cpp プロジェクト: 289997171/cocos2d-x
TMXOrthoXMLFormatTest::TMXOrthoXMLFormatTest()
{
    // this test tests for:
    // 1. load xml format tilemap
    // 2. gid lower than firstgid is ignored
    // 3. firstgid in tsx is ignored, tile property in tsx loaded correctly.
    auto map = TMXTiledMap::create("TileMaps/xml-test.tmx");
    addChild(map, 0, kTagTileMap);
    
    auto s = map->getContentSize();
    log("ContentSize: %f, %f", s.width,s.height);
    
    auto& children = map->getChildren();
    for(const auto &node : children) {
        auto child = static_cast<SpriteBatchNode*>(node);
        child->getTexture()->setAntiAliasTexParameters();
    }
    
    for(int i=24;i<=26;i++){
        log("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()["name"].asString().c_str());
    }
    
    auto action = ScaleBy::create(2, 0.5f);
    map->runAction(action);
}
コード例 #2
0
ファイル: HelloWorldScene.cpp プロジェクト: Ratel13/book-code
void HelloWorld::createMapAndGetTileProperity()
{
    auto map = TMXTiledMap::create("ortho-objects.tmx");
    addChild(map, 0, 1);
    auto layer = map->getLayer("logic");
    Point playerindex = Point(0,0);
    int tilegid = layer->getTileGIDAt(playerindex);
	if(tilegid > 0){
        log("Properties:%s",map->getPropertiesForGID(tilegid).asValueMap()["collion"].asString().c_str());
    }
}
コード例 #3
0
ファイル: TileMapTest2.cpp プロジェクト: AnySDK/Sample_Lua
TMXTilePropertyTestNew::TMXTilePropertyTestNew()
{
    auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/ortho-tile-property.tmx");
    addChild(map ,0 ,kTagTileMap);

    for(int i=1;i<=20;i++){
        for(const auto& value : map->getPropertiesForGID(i).asValueMap())
        {
            log("GID:%i, Properties:%s, %s", i, value.first.c_str(), value.second.asString().c_str());
        }
    }
}
コード例 #4
0
ファイル: TileMapTest2.cpp プロジェクト: AnySDK/Sample_Lua
TMXOrthoXMLFormatTestNew::TMXOrthoXMLFormatTestNew()
{
    // this test tests for:
    // 1. load xml format tilemap
    // 2. gid lower than firstgid is ignored
    // 3. firstgid in tsx is ignored, tile property in tsx loaded correctly.
    auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/xml-test.tmx");
    addChild(map, 0, kTagTileMap);
    
    auto s = map->getContentSize();
    log("ContentSize: %f, %f", s.width,s.height);
    
    for(int i=24;i<=26;i++){
        log("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()["name"].asString().c_str());
    }
    
    auto action = ScaleBy::create(2, 0.5f);
    map->runAction(action);
}