本文整理汇总了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;
}
示例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();
}