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


C++ Director::setContentScaleFactor方法代码示例

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


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

示例1: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* pDirector = Director::sharedDirector();
    EGLView* pEGLView = EGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

    // Set the design resolution
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

	Size frameSize = pEGLView->getFrameSize();
    
    vector<string> searchPath;

    // In this demo, we select resource according to the frame's height.
    // If the resource size is different from design resolution size, you need to set contentScaleFactor.
    // We use the ratio of resource's height to the height of design resolution,
    // this can make sure that the resource's height could fit for the height of design resolution.

    // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height > mediumResource.size.height)
	{
        searchPath.push_back(largeResource.directory);

        pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
	}
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height)
    {
        searchPath.push_back(mediumResource.directory);
        
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
	else
    {
        searchPath.push_back(smallResource.directory);

        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    
    // set searching path
    FileUtils::sharedFileUtils()->setSearchPaths(searchPath);
	
    // turn on display FPS
    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    Scene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:58,代码来源:AppDelegate.cpp

示例2: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director *pDirector = Director::sharedDirector();

    pDirector->setOpenGLView(EGLView::sharedOpenGLView());

    Size screenSize = EGLView::sharedOpenGLView()->getFrameSize();
    //Size designSize = CCSizeMake(1600, 900);
    Size designSize = CCSizeMake(12*101, 12*81);
    std::vector<std::string> searchPaths;

    if (screenSize.height > 320)
    {
        searchPaths.push_back("hd");
        searchPaths.push_back("sd");
        Size resourceSize = CCSizeMake(12*101, 12*81);
        //pDirector->setContentScaleFactor(960.0f/designSize.height);
        ///pDirector->setContentScaleFactor(1.0f);
        pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
    }
    else
    {
        searchPaths.push_back("sd");
        pDirector->setContentScaleFactor(640.0f/designSize.height);
    }

    FileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

    EGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);

    // turn on display FPS
    //pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    //Scene *pScene = GameplayScene::scene();
    Scene *scene;

    if (_levelToLaunch == nullptr)
    {
        scene = MainMenuLayer::scene();
    }
    else
    {
        auto ms = Bomber::Frontend::MenuSelections::getInstance();
        ms->setLevelFilename(_levelToLaunch);
        ms->setLevelName("test");
        scene = GameplayScene::scene();
    }

    // run
    pDirector->runWithScene(scene);

    return true;
}
开发者ID:reneklacan,项目名称:bomber,代码行数:57,代码来源:AppDelegate.cpp

示例3: resizeGL

void MyQGLWidget::resizeGL(int w, int h)
{
    if (Display::IsRetinaDisplay())
    {
        w >>= 1;
        h >>= 1;
    }

    if (!mLazyInit)
    {
        mLazyInit = true;

        EGLView* view = EGLView::sharedOpenGLView();
        view->setFrameSize(w, h);

        Director* director = Director::sharedDirector();
        director->setContentScaleFactor(1);
        director->setProjection(kDirectorProjection2D);
        //director->setDisplayStats(true);
        director->setOpenGLView(view);

        connect(&mTimer, SIGNAL(timeout()), this, SLOT(updateGL()));
        mTimer.start();

        Scene* scene = Scene::create();
        director->pushScene(scene);

        setMouseTracking(true);
    }

    EGLView* view = EGLView::sharedOpenGLView();
    view->setFrameSize(w, h);
    view->setDesignResolutionSize(w, h, kResolutionNoBorder);
}
开发者ID:UIKit0,项目名称:ccgraphedit,代码行数:34,代码来源:myqglwidget.cpp

示例4: setDesignResolution

void AppDelegate::setDesignResolution()
{
	Director* director = Director::getInstance();
	EGLView* glView = EGLView::getInstance();

	Size frameSize = glView->getFrameSize();  
	vector<string> searchPath;

#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	if (frameSize.height > small5Resource.size.height)
	{
		log("ipadhd resource selected");

		designResolutionSize = largeResource.size;
		searchPath.push_back(largeResource.directory);
		director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
	}
	else if (frameSize.height > mediumResource.size.height)
	{
		log("iphone5 resource selected");

		designResolutionSize = small5Resource.size;
		searchPath.push_back(small5Resource.directory);
		director->setContentScaleFactor(MIN(small5Resource.size.height/designResolutionSize.height, small5Resource.size.width/designResolutionSize.width));
	}
	else if (frameSize.height > smallResource.size.height)
	{
		log("ipad resource selected");

		designResolutionSize = mediumResource.size;
		searchPath.push_back(mediumResource.directory);
		director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
	}
	else if (frameSize.height > small3Resource.size.height)
	{
		log("iphone resource selected");

		designResolutionSize = smallResource.size;
		searchPath.push_back(smallResource.directory);
		director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
	}
	else
	{
		log("iphone3 resource selected");

		designResolutionSize = small3Resource.size;
		searchPath.push_back(small3Resource.directory);
		director->setContentScaleFactor(MIN(small3Resource.size.height/designResolutionSize.height, small3Resource.size.width/designResolutionSize.width));
	}
#else
	log("android resource selected");

	designResolutionSize = androidResource.size;
	searchPath.push_back(androidResource.directory);
	director->setContentScaleFactor(MIN(androidResource.size.height/designResolutionSize.height, androidResource.size.width/designResolutionSize.width));
#endif

	// set searching path
	FileUtils::getInstance()->setSearchPaths(searchPath);
}
开发者ID:rtothecore,项目名称:GrandBlue,代码行数:60,代码来源:AppDelegate.cpp

示例5: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director *director = Director::getInstance();

    director->setOpenGLView(EGLView::getInstance());

    Size screenSize = EGLView::getInstance()->getFrameSize();
    Size designSize = Size(480, 320);
    std::vector<std::string> searchPaths;

    if (screenSize.height > 320)
    {
        searchPaths.push_back("hd");
        searchPaths.push_back("sd");
        director->setContentScaleFactor(640.0f/designSize.height);
    }
    else
    {
        searchPaths.push_back("sd");
        director->setContentScaleFactor(320.0f/designSize.height);
    }

    FileUtils::getInstance()->setSearchPaths(searchPaths);

    EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER);

    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    Scene *scene = HelloWorld::scene();

    // run
    director->runWithScene(scene);

    return true;
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:40,代码来源:AppDelegate.cpp

示例6: changeImageResolutionSize

void ScreenSizeManager::changeImageResolutionSize(float myImageResolutionWidth,
                                                  float myImageResolutionHeight)
{
    CCAssert(_isInit, "Need to ScreenSizeManager::init!");
    
    // cocos2d-x v3.0.0 이상만 지원.
    CCAssert(0x00030000 <= COCOS2D_VERSION, "ScreenSizeManager need to cocos2d-x 3.0.0 or higher!");
    
    float kScaleFactor = 1.0f;
    
    if ( _isFixedScreenSize )
    {
        
    }
    else
    {
        if ( _isScaleHeight )
        {
            //
            // 높이를 기준으로 처리...
            int kRemainHeight = (int)myImageResolutionHeight % (int)_imageResolutionSize.height;
            
            if (0 != kRemainHeight)
            {
                float kRatio = kRemainHeight / _imageResolutionSize.height;
                
                if (myImageResolutionHeight < _imageResolutionSize.height)
                {
                    kScaleFactor = kRatio;
                }
                else
                {
                    kScaleFactor += kRatio;
                }
            }
            
            kScaleFactor = myImageResolutionHeight / _imageResolutionSize.height;
            
        }
        else
        {
            // 폭을 기준으로 처리...
            int kRemainWidth = (int)myImageResolutionWidth % (int)_imageResolutionSize.width;
            
            if (0 != kRemainWidth)
            {
                float kRatio = kRemainWidth / _imageResolutionSize.width;
                
                if (myImageResolutionWidth < _imageResolutionSize.width)
                {
                    kScaleFactor = kRatio;
                }
                else
                {
                    kScaleFactor += kRatio;
                }
                
            }
            
            kScaleFactor = myImageResolutionWidth / _imageResolutionSize.width;
        }
    }
    
    Director* kDirector = CCDirector::getInstance();
    kDirector->setContentScaleFactor(kScaleFactor);
}
开发者ID:OhByeongYun,项目名称:1989flanker-cpp,代码行数:66,代码来源:ScreenSizeManager.cpp

示例7: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *pDirector = Director::getInstance();
    pDirector->setOpenGLView(EGLView::getInstance());
    pDirector->setProjection(Director::Projection::_2D);


    Size screenSize = EGLView::getInstance()->getFrameSize();

    Size designSize = Size(320, 480);
    Size resourceSize = Size(320, 480);
    
    std::vector<std::string> searchPaths;
    std::vector<std::string> resDirOrders;
    
    Application::Platform platform = Application::getInstance()->getTargetPlatform();
    if (platform == Application::Platform::OS_IPHONE || platform == Application::Platform::OS_IPAD || platform == Application::Platform::OS_MAC)
    {
        searchPaths.push_back("Published-iOS"); // Resources/Published-iOS
        FileUtils::getInstance()->setSearchPaths(searchPaths);

        if (screenSize.height > 480)
        {
            resourceSize = Size(640, 960);
            resDirOrders.push_back("resources-iphonehd");
        }
        else
        {
            resDirOrders.push_back("resources-iphone");
        }
        
        FileUtils::getInstance()->setSearchResolutionsOrder(resDirOrders);
    }
    else if (platform == Application::Platform::OS_ANDROID || platform == Application::Platform::OS_WINDOWS)
    {
        // Comments it since opengles2.0 only supports texture size within 2048x2048.
//        if (screenSize.height > 1024)
//        {
//            resourceSize = Size(1280, 1920);
//            resDirOrders.push_back("resources-xlarge");
//            resDirOrders.push_back("");
//        }
//        else 
        if (screenSize.height > 960)
        {
            resourceSize = Size(640, 960);
            resDirOrders.push_back("resources-large");
            resDirOrders.push_back("resources-medium");
            resDirOrders.push_back("resources-small");
        }
        else if (screenSize.height > 480)
        {
            resourceSize = Size(480, 720);
            resDirOrders.push_back("resources-medium");
            resDirOrders.push_back("resources-small");
        }
        else
        {
            resourceSize = Size(320, 568);
            resDirOrders.push_back("resources-small");
        }
        
        FileUtils::getInstance()->setSearchResolutionsOrder(resDirOrders);
    }
    pDirector->setContentScaleFactor(resourceSize.width/designSize.width);

    EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL);
    
    // turn on display FPS
    pDirector->setDisplayStats(true);
    
    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    
    ScriptingCore* sc = ScriptingCore::getInstance();
    sc->addRegisterCallback(register_all_cocos2dx);
    sc->addRegisterCallback(register_all_cocos2dx_extension);
    sc->addRegisterCallback(register_cocos2dx_js_extensions);
    sc->addRegisterCallback(jsb_register_chipmunk);
    sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
    sc->addRegisterCallback(register_CCBuilderReader);
    sc->addRegisterCallback(jsb_register_system);
    sc->addRegisterCallback(JSB_register_opengl);
    
    sc->start();

    js_log("RUNNING Main");
    ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
    ScriptingCore::getInstance()->runScript("main.js");
       
    return true;
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:94,代码来源:AppDelegate.cpp


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