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


C++ CCDirector::getDeviceOrientation方法代码示例

本文整理汇总了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;
		}
	}
开发者ID:DmitriyKirakosyan,项目名称:testNinjaX,代码行数:32,代码来源:CCGrid_mobile.cpp

示例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);
}
开发者ID:JoeHu,项目名称:magicpet,代码行数:58,代码来源:CGameLetter.cpp


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