本文整理汇总了C++中CCDirector::getDeviceOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDirector::getDeviceOrientation方法的具体用法?C++ CCDirector::getDeviceOrientation怎么用?C++ CCDirector::getDeviceOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDirector
的用法示例。
在下文中一共展示了CCDirector::getDeviceOrientation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyLandscape
// This routine can be merged with Director
void CCGridBase::applyLandscape(void)
{
CCDirector *pDirector = CCDirector::sharedDirector();
CCSize winSize = pDirector->getDisplaySizeInPixels();
float w = winSize.width / 2;
float h = winSize.height / 2;
ccDeviceOrientation orientation = pDirector->getDeviceOrientation();
switch (orientation)
{
case CCDeviceOrientationLandscapeLeft:
glTranslatef(w,h,0);
glRotatef(-90,0,0,1);
glTranslatef(-h,-w,0);
break;
case CCDeviceOrientationLandscapeRight:
glTranslatef(w,h,0);
glRotatef(90,0,0,1);
glTranslatef(-h,-w,0);
break;
case CCDeviceOrientationPortraitUpsideDown:
glTranslatef(w,h,0);
glRotatef(180,0,0,1);
glTranslatef(-w,-h,0);
break;
default:
break;
}
}
示例2: preVisitWithClippingRect
//---------------------------------------------------------------
//
//
void CLetterMoveLayer::preVisitWithClippingRect(CCRect clipRect)
{
if (!this->getIsVisible())
return;
glEnable(GL_SCISSOR_TEST);
CCDirector *director = CCDirector::sharedDirector();
CCSize size =director->getWinSize();
CCPoint origin = this->convertToWorldSpaceAR(clipRect.origin);
CCPoint topRight =this->convertToWorldSpaceAR(ccpAdd(clipRect.origin, ccp(clipRect.size.width, clipRect.size.height)));
CCRect scissorRect = CCRectMake(origin.x, origin.y, topRight.x-origin.x, topRight.y-origin.y);
// transform the clipping rectangle to adjust to the current screen
// orientation: the rectangle that has to be passed into glScissor is
// always based on the coordinate system as if the device was held with the
// home button at the bottom. the transformations account for different
// device orientations and adjust the clipping rectangle to what the user
// expects to happen.
ccDeviceOrientation orientation =director->getDeviceOrientation();
switch (orientation) {
case kCCDeviceOrientationPortrait:
break;
case kCCDeviceOrientationPortraitUpsideDown:
scissorRect.origin.x = size.width-scissorRect.size.width-scissorRect.origin.x;
scissorRect.origin.y = size.height-scissorRect.size.height-scissorRect.origin.y;
break;
case kCCDeviceOrientationLandscapeLeft:
{
float tmp = scissorRect.origin.x;
scissorRect.origin.x = scissorRect.origin.y;
scissorRect.origin.y = size.width-scissorRect.size.width-tmp;
tmp = scissorRect.size.width;
scissorRect.size.width = scissorRect.size.height;
scissorRect.size.height = tmp;
}
break;
case kCCDeviceOrientationLandscapeRight:
{
float tmp = scissorRect.origin.y;
scissorRect.origin.y = scissorRect.origin.x;
scissorRect.origin.x = size.height-scissorRect.size.height-tmp;
tmp = scissorRect.size.width;
scissorRect.size.width = scissorRect.size.height;
scissorRect.size.height = tmp;
}
break;
}
// Handle Retina
scissorRect = CC_RECT_POINTS_TO_PIXELS(scissorRect);
glScissor((GLint) scissorRect.origin.x, (GLint) scissorRect.origin.y,
(GLint) scissorRect.size.width, (GLint) scissorRect.size.height);
}