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


C++ TextureManager::add方法代码示例

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


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

示例1: loadLevel

void LevelManager::loadLevel(Level* lvl) {
    printf("STARTING TO LOAD LEVEL \n" );

    std::cout << "Entities::start " << cg::Registry::instance()->size() << "\n";

    _currentLevel = lvl;
    _currentClues = 0;
    static_cast<Scene*>(cg::Registry::instance()->get("Scene"))->reset();

    MaterialManager* materialManager = dynamic_cast<MaterialManager*>(cg::Registry::instance()->get("MaterialManager"));
    TextureManager* textureManager = dynamic_cast<TextureManager*>(cg::Registry::instance()->get("TextureManager"));

    materialManager->clear();
    std::list<Material*>::iterator matit;
    for(matit = lvl->getMaterials()->begin(); matit != lvl->getMaterials()->end(); matit++) {
        materialManager->add(*matit);
    }

    textureManager->clear();
    std::list<Texture*>::iterator texit;
    textureManager->addMap(lvl->getMapTex());
    for(texit = lvl->getTextures()->begin(); texit != lvl->getTextures()->end(); texit++) {
        textureManager->add(*texit);
    }


    printf("LEVEL MANAGER: REMOVING PREVIOUS ENTITIES\n");
    //clearing old ones (if there are any)
    cg::View* v1 = static_cast<cg::View*>(cg::Registry::instance()->get("view1"));
    std::list<std::string>::iterator entitiesit;
    for(entitiesit = _currentEntities->begin(); entitiesit != _currentEntities->end(); entitiesit++) {
        v1->unlinkEntity(*entitiesit);
        cg::Registry::instance()->remove(*entitiesit);
    }

    std::cout << "Entities::after_unlink " << cg::Registry::instance()->size() << "\n";
    DebugManager* dm = static_cast<DebugManager*>(cg::Registry::instance()->get("DebugManager"));
    std::cout << "Debugmanager::Before " << dm->getListsSize() << "\n";


    printf("LEVEL MANAGER: REMOVING DEBUG LISTENERS\n");
    //removing everything registered for Debug (Ninja is always there)
    //DebugManager* dm = static_cast<DebugManager*>(cg::Registry::instance()->get("DebugManager"));
    dm->dispose();
    dm->disableDebug();

    std::cout << "Debugmanager::After " << dm->getListsSize() << "\n";

    CollisionManager* cm = static_cast<CollisionManager*>(cg::Registry::instance()->get("CollisionManager"));
    std::cout << "Collision::Before " << cm->getListsSize() << "\n";


    printf("LEVEL MANAGER: REMOVING COLLISION LISTENERS\n");
    //removing everything except Ninja from Collisions
    //CollisionManager* cm = static_cast<CollisionManager*>(cg::Registry::instance()->get("CollisionManager"));
    cm->dispose();


    std::cout << "Collision::After " << cm->getListsSize() << "\n";
    std::cout << "Entities::after_managers " << cg::Registry::instance()->size() << "\n";

    _currentEntities->clear();

    std::cout << "Entities::after_clean_entities " << cg::Registry::instance()->size() << "\n";

    printf("LEVEL MANAGER: STARTING TO LOAD HEIGHT MAP\n");
    ImageLoaderHeightMap* ilhm = static_cast<ImageLoaderHeightMap*>(cg::Registry::instance()->get("mappedterrain"));
    if(ilhm != NULL)
        ilhm->setHeightMap(LEVEL_PATH + _currentLevel->getHeightMap());
    else {
        ilhm = new ImageLoaderHeightMap("mappedterrain", LEVEL_PATH + _currentLevel->getHeightMap());
        cg::Registry::instance()->add(ilhm);
    }

    std::cout << "Entities::after_heightmap " << cg::Registry::instance()->size() << "\n";

    printf("LEVEL MANAGER: STARTING TO LOAD ITEM MAP\n");
    ImageLoaderItemMap* ilim = static_cast<ImageLoaderItemMap*>(cg::Registry::instance()->get("mappeditems"));
    if(ilim != NULL)
        ilim->setItemMap(LEVEL_PATH + _currentLevel->getHeightMap(), LEVEL_PATH + _currentLevel->getItemMap());
    else {
        ilim = new ImageLoaderItemMap("mappeditems", LEVEL_PATH + _currentLevel->getHeightMap(), LEVEL_PATH + _currentLevel->getItemMap());
        cg::Registry::instance()->add(ilim);
    }


    for(entitiesit = _currentEntities->begin(); entitiesit != _currentEntities->end(); entitiesit++) {
        cg::Registry::instance()->get(*entitiesit)->init();
    }

    //reset ninja position
    printf("LEVEL MANAGER: RESETING NINJA POSITION\n");
    Ninja* ninja = dynamic_cast<Ninja*>(cg::Registry::instance()->get("Ninja"));
    ninja->reset();

    static_cast<Camera*>(cg::Registry::instance()->get("Camera"))->mainCamera();

    std::cout << "Entities::after_itemmap " << cg::Registry::instance()->size() << "\n";
    std::cout << "Debugmanager::After " << dm->getListsSize() << "\n";
    std::cout << "Collision::After " << cm->getListsSize() << "\n";
//.........这里部分代码省略.........
开发者ID:Meldow,项目名称:HarudoboirudoNinja,代码行数:101,代码来源:LevelManager.cpp


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