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


C++ EGLView::getFrameSize方法代码示例

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


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

示例1: 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

示例2: 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

示例3: resolve

    void MultiResolution::resolve()
    {
        EGLView *eglView = EGLView::getInstance();
        Size rsize;
        const Size fsize = eglView->getFrameSize();
        const bool v = fsize.height / fsize.width > 1.0f;
        const Size size = swap(fsize, v);
        const Size dsize = swap(Size(960, 640), v);

        std::vector<std::string> order;

        ApplicationProtocol::Platform platform = Application::getInstance()->getTargetPlatform();
        if(platform == ApplicationProtocol::Platform::OS_IPHONE || platform == ApplicationProtocol::Platform::OS_IPAD)
        {
            if(size.height > 768)
            {
                rsize.setSize(2048, 1536);
                order.push_back(names[static_cast<int>(ResolutionType::iPadHD)]);
            }
            else if(size.height > 640)
            {
                rsize.setSize(1536, 768);
                order.push_back(names[static_cast<int>(ResolutionType::iPad)]);
            }
            else if(size.height > 480)
            {
                if(size.width < 1136)
                    rsize.setSize(960, 649);
                else
                    rsize.setSize(1136, 640);
                order.push_back(names[static_cast<int>(ResolutionType::iPhoneHD)]);
            }
            else
            {
                rsize.setSize(480, 320);
                order.push_back(names[static_cast<int>(ResolutionType::iPhone)]);
            }
        }
        else if(platform == ApplicationProtocol::Platform::OS_ANDROID)
        {
            if(size.height > 1200)
            {
                rsize.setSize(1200, 800);
                order.push_back(names[static_cast<int>(ResolutionType::XLarge)]);
            }
            else if(size.height > 960)
            {
                rsize.setSize(960, 640);
                order.push_back(names[static_cast<int>(ResolutionType::Large)]);
            }
            else if(size.height > 480)
            {
                rsize.setSize(720, 480);
                order.push_back(names[static_cast<int>(ResolutionType::Medium)]);
            }
            else
            {
                rsize.setSize(568, 320);
                order.push_back(names[static_cast<int>(ResolutionType::Small)]);
            }
        }

        rsize = swap(rsize, v);
        Director::getInstance()->setContentScaleFactor(dsize.width / rsize.width);
        eglView->setDesignResolutionSize(rsize.width, rsize.height,/* kResolutionFixedHeight */ ResolutionPolicy::SHOW_ALL);
        FileUtils::getInstance()->setSearchPaths(searchPaths);
        FileUtils::getInstance()->setSearchResolutionsOrder(order);
    }
开发者ID:Giemsa,项目名称:oreore,代码行数:68,代码来源:MultiResolution.cpp

示例4: OnGLFWMouseMoveCallBack

void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{
    s_mouseX = (float)x;
    s_mouseY = (float)y;
    EGLView* eglView = EGLView::getInstance();
    if(nullptr == eglView) return;
    
    s_mouseX /= eglView->getFrameZoomFactor();
    s_mouseY /= eglView->getFrameZoomFactor();
    
    if(s_captured)
    {
        if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
        {
            int id = 0;
            eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
        }
    }
}
开发者ID:Gamex,项目名称:GameX,代码行数:19,代码来源:CCEGLView.cpp


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