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


C++ TApplication::GetScreenWidth方法代码示例

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


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

示例1: Create

Boolean CCEGLView::Create(int nWidthInPoints, int nHeightInPoints)
{
    // record the window size in points
    m_tSizeInPoints.SetWidth(nWidthInPoints);
    m_tSizeInPoints.SetHeight(nHeightInPoints);

    // get the screen size
    TApplication* pApp = TApplication::GetCurrentApplication();
    Int32 nWidth  = pApp->GetScreenWidth();
    Int32 nHeight = pApp->GetScreenHeight();

    // calculate the factor and the rect of viewport
    m_fScreenScaleFactor =  MIN((float)nWidth / nWidthInPoints, (float)nHeight / nHeightInPoints);
    int viewPortW = (int)(m_tSizeInPoints.Width() * m_fScreenScaleFactor);
    int viewPortH = (int)(m_tSizeInPoints.Height() * m_fScreenScaleFactor);
    m_rcViewPort.SetX((nWidth - viewPortW) / 2);
    m_rcViewPort.SetY((nHeight - viewPortH) / 2);
    m_rcViewPort.SetWidth(viewPortW);
    m_rcViewPort.SetHeight(viewPortH);

    Boolean bRet = TWindow::Create(&TRectangle(0, 0, nWidth, nHeight));

    if (bRet)
    {
        s_pMainWindow = this;
    }

    return bRet;
}
开发者ID:flyingpacer,项目名称:cocos2d-x-samples,代码行数:29,代码来源:CCEGLView_wophone.cpp

示例2: getDiffResolutionPath

const char* getDiffResolutionPath(const char *pszPath)
{
    CCString *pRet = new CCString(pszPath);
    pRet->autorelease();

    do 
    {
        TApplication* pApp = TApplication::GetCurrentApplication();
        CC_BREAK_IF(!pApp);

        // get the Resolution
        int nScreenWidth  = pApp->GetScreenWidth();
        int nScreenHeight = pApp->GetScreenHeight();

        // it's default resolution, do nothing
        CC_BREAK_IF(nScreenWidth == 320 && nScreenHeight == 480);

        if (nScreenWidth == 480 && nScreenHeight == 800)
        {
            // it's WVGA
            CC_BREAK_IF(pRet->m_sString.find("@WVGA") != -1);

            std::string filePathWithoutExtension = pszPath;
            std::string extension = "";
            std::string filePath = pszPath;
            int nExPos = filePath.find_last_of(".");

            if (nExPos != -1)
            {
                filePathWithoutExtension = filePath.substr(0, nExPos);
                extension = filePath.substr(nExPos);
            }

            // new path, add "@WVGA" before the extension
            pRet->m_sString = filePathWithoutExtension + "@WVGA" + extension;

            // not find the resource of new path,use the original path
            if (! isResourceExist(pRet->m_sString.c_str()))
            {
                pRet->m_sString = filePath;
            }
        }
        else
        {
            // not support resolution
            CCAssert(0, "it's not supportted resolution.");
        }
    } while (0);

    return pRet->m_sString.c_str();
}
开发者ID:issamux,项目名称:WebGame,代码行数:51,代码来源:CCFileUtils_wophone.cpp


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