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


C++ CCEGLView::getScaleX方法代码示例

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


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

示例1: dumpCocos2dx

///////////////////////////////////////////
//@android: for test only
void dumpCocos2dx()
{
	string strLine = "@@------------------------------------------------------------{{\r\n";
	char szInfo[1024] = "";

	CCLog( strLine.c_str() );
	__flog( strLine.c_str());

	// dump NDDirector & CCDirector
	{
		sprintf( szInfo,
			"[CCDirector] size in Points  (%d, %d)\r\n"
			"[CCDirector] size in Pixels  (%d, %d)\r\n"
			"[CCDirector] content scale = %.1f\r\n",

			(int)CCDirector::sharedDirector()->getWinSize().width,
			(int)CCDirector::sharedDirector()->getWinSize().height,

			(int)CCDirector::sharedDirector()->getWinSizeInPixels().width,
			(int)CCDirector::sharedDirector()->getWinSizeInPixels().height,

			CCDirector::sharedDirector()->getContentScaleFactor()
			);

		CCLog( szInfo );
		__flog( szInfo );
	}

	// dump EGL view
	{
		CCEGLView* pkEglView = CCDirector::sharedDirector()->getOpenGLView();
		if (pkEglView)
		{
			sprintf( szInfo, 
				"\r\n"
				"[EGLVIEW] frame     size (%d, %d)\t\t[AKA: Screen Size]\r\n"
				"[EGLVIEW] designed  size (%d, %d)\r\n"
				"[EGLVIEW] scale          (%.2f, %.2f)\r\n"
				"\r\n"
				"[EGLVIEW] viewport  org  (%d, %d)\r\n"
				"[EGLVIEW] viewport  size (%d, %d)\r\n"
				"\r\n"
				"[EGLVIEW] visible   org  (%d, %d)\r\n"
				"[EGLVIEW] visible   size (%d, %d)\r\n"
				"\r\n"
				"[EGLVIEW] retina enabled (%d)\r\n"
				//"[EGLVIEW] resolution policy (%d)\r\n"
				,
				/*frame*/	(int)pkEglView->getFrameSize().width,			(int)pkEglView->getFrameSize().height, 
				/*designed*/(int)pkEglView->getSize().width,				(int)pkEglView->getSize().height, 
				/*scale*/	pkEglView->getScaleX(), pkEglView->getScaleY(),

				/*viewport*/(int)pkEglView->getViewPortRect().origin.x,	(int)pkEglView->getViewPortRect().origin.y,
				/*viewport*/(int)pkEglView->getViewPortRect().size.width,	(int)pkEglView->getViewPortRect().size.height,

				/*vis org*/	(int)pkEglView->getVisibleOrigin().x,			(int)pkEglView->getVisibleOrigin().y,
				/*vis size*/(int)pkEglView->getVisibleSize().width,		(int)pkEglView->getVisibleSize().height,
				
				/*retina*/	(int)pkEglView->isRetinaEnabled()
				///*policy*/	(int)eglView->m_eResolutionPolicy
				);

			CCLog( szInfo );
			__flog( szInfo );
		}
	}

	strLine = "@@------------------------------------------------------------}}\r\n";
	CCLog( strLine.c_str());
	__flog_flush( strLine.c_str());
}
开发者ID:korman,项目名称:Temp,代码行数:73,代码来源:NDGameApplication.cpp

示例2: myWndProcHook


//.........这里部分代码省略.........
			case 'S':   //向下
				{
					pt = ccp(62, 290);
				}
				break;
			case 'J':   //攻击
				{
					pt = ccp(367, 277);
				}
				break;
			case 'K':   //跳跃
				{
					pt = ccp(445, 247);
				}
				break;
			default:
				return 0;
			}
			if (GetKeyState('D') & 0x8000)
			{
				if (GetKeyState('W') & 0x8000)      //右上角
				{
					pt = ccp(91, 227);
				}
				else if (GetKeyState('S') & 0x8000) //右下角
				{
					pt = ccp(91, 284);
				}
			}
			else if (GetKeyState('A') & 0x8000)
			{
				if (GetKeyState('W') & 0x8000)      //左上角
				{
					pt = ccp(36, 227);
				}
				else if (GetKeyState('S') & 0x8000) //左下角
				{
					pt = ccp(36, 284);
				}
			}

			CCEGLView* eglView = CCEGLView::sharedOpenGLView();
			CCSize originalDesignResolutionSize = CCSizeMake(480, 320);     //原始的设计分辨率大小
			ResolutionPolicy eResolutionPolicy = kResolutionFixedWidth;     //分辨率策略
			CCSize obDesignResolutionSize = eglView->getDesignResolutionSize();
			int offsetWidth = obDesignResolutionSize.width - originalDesignResolutionSize.width;
			int offsetheight = obDesignResolutionSize.height - originalDesignResolutionSize.height;
			CCSize obScreenSize = eglView->getFrameSize();
			int offsetWidth2 = obScreenSize.width - originalDesignResolutionSize.width;
			int offsetheight2 = obScreenSize.height - originalDesignResolutionSize.height;
			switch (eResolutionPolicy)
			{
			case kResolutionExactFit:
				{
					//...
				}
				break;
			case kResolutionNoBorder:
				{
					//...
				}
				break;
			case kResolutionShowAll:
				{
					pt.x += offsetWidth2 / 2;
					pt.y += offsetheight2 / 2;
				}
				break;
			case kResolutionFixedHeight:
				{
					//...
				}
				break;
			case kResolutionFixedWidth:
				{
					pt.y += offsetheight;
				}
				break;
			}

			pt.x *= eglView->getScaleX();
			pt.y *= eglView->getScaleY();

			int id = wParam;
			if (message == WM_KEYDOWN)
			{
				eglView->handleTouchesBegin(1, &id, &pt.x, &pt.y);
			}
			else
			{
				eglView->handleTouchesEnd(1, &id, &pt.x, &pt.y);
			}

			*pProcessed = TRUE;
		}
		break;
	}

	return 0;
}
开发者ID:jfojfo,项目名称:MyPompaDroid,代码行数:101,代码来源:main.cpp

示例3: enableMutliResolutionSupport


//.........这里部分代码省略.........
        pDirector->setContentScaleFactor(4.f);
    }
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.width > smallResource.size.width  && maxTextureSize >= 1024) {
        CCLOG("Select MEDIUM (hd) resource...");
        resOrder.insert(resOrder.begin(), mediumResource.directory);
        /// pDirector->setContentScaleFactor(mediumResource.size.width/designResolutionSize.width);
        pDirector->setContentScaleFactor(2.f);
        scaledGraphics = frameSize.width > mediumResource.size.width; // have scale down because of max texture size too small?
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
    else {
        CCLOG("Select SMALL (sd) resource...");
        resOrder.insert(resOrder.begin(), smallResource.directory);
        /// pDirector->setContentScaleFactor(smallResource.size.width/designResolutionSize.width);
        pDirector->setContentScaleFactor(1.f);
        scaledGraphics = frameSize.width > smallResource.size.width; // have scale down because of max texture size too small?
    }

    /// Show an error message if we scaled down the graphics or the max texture size is too small
    if (scaledGraphics || maxTextureSize < 512) {
        CCLOGERROR("Unsupported max texture size: %d",maxTextureSize);
        CCMessageBox("We detected graphics limitation which might prevent the app to work properly or to use HD graphics (max texture too small)", "ERROR");
    }

    /// Bug fix: the resolution directory must have a trailing slash (e.g. hd/ or sd/) or
    /// CCFileUtils::getFullPathForDirectoryAndFilename() will not work correclty on iOS if
    /// both search paths and resolution order are defined (missing slash between directory and filename).
    /// We now use setSearchResolutionsOrder instead of addSearchResolutionsOrder because
    /// addSearchResolutionsOrder simply add the string to the list of the resolution order without adding the trailing slash.
    /// setSearchResolutionOrder takes care of adding the trailing slash if missing.
    /// See. http://discuss.cocos2d-x.org/t/search-paths-and-resolutions-order-issue-on-ios/14424
    fileUtils.setSearchResolutionsOrder(resOrder);

    /// Set the font sizes
    for (int i = 0; i < 4; i++)
        smFontsSize[i]  *= designResolutionSize.width / smallResource.size.width;

    ////////////////// Trace settings... /////////////////
#if COCOS2D_DEBUG > 0

    /// Redirect standard output and error stream to file
    //freopen(fileUtils.getWritablePath().append("cocos2d.log").c_str(), "a+", stdout);
    //freopen(fileUtils.getWritablePath().append("cocos2d.log").c_str(), "a+", stderr);

    /// In debug mode we change the default search path to the following.
    std::vector<std::string> paths;
    paths.push_back(fileUtils.getWritablePath()); /// First we search the writable path root for assets download on-the-fly (see command.h/cpp)
    paths.push_back(fileUtils.getWritablePath().append("lua")); /// Secondly we search in the lua folder below the writable root for lua script
    paths.push_back(""); /// Finally we look in the default resource path (empty string)

    fileUtils.setSearchPaths(paths);

    TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform();
    if (platform == kTargetAndroid || platform == kTargetIpad || platform == kTargetIphone) {
        /// Purge the writable folder
        CCLOG("Removing files from the assets staging area (writable path)...");
        /// TODO on mac getWritablePath is "/Users/lzubiaur/Library/Caches/".
        /// So it should not be wipe out but temporary assets should be written in a subfolder
        emptyFolder(fileUtils.getWritablePath());
    }

    CCLOG("Real screen size: %.0fx%.0f", pEGLView->getFrameSize().width, pEGLView->getFrameSize().height);
    CCLOG("Design resolution size: %.0fx%.0f", pEGLView->getDesignResolutionSize().width, pEGLView->getDesignResolutionSize().height);
    CCLOG("Content scale factor: %f", pDirector->getContentScaleFactor());
    CCLOG("Scale x:%f y:%f", pEGLView->getScaleX(), pEGLView->getScaleY());
    CCLOG("Visible origin: x:%.0f y:%.0f",pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y);
    CCLOG("Visible size: %.0fx%.0f", pEGLView->getVisibleSize().width, pEGLView->getVisibleSize().height);

    /// Log the search paths
    std::string searchPath;
    for (const std::string s : fileUtils.getSearchPaths())
        searchPath.append(' ' + s);
    CCLOG("Search path: %s", searchPath.c_str());

    /// Log the search resolution order
    std::string resolutionOrder;
    for (const std::string s : fileUtils.getSearchResolutionsOrder())
        resolutionOrder.append(' ' + s);
    CCLOG("Search resolution order: %s", resolutionOrder.c_str());
    CCLOG("Writeable path: %s", fileUtils.getWritablePath().c_str());
    CCLOG("Lua version: %s",LUA_VERSION);

    /// CCLOG("Websocket version %s",lws_get_library_version());

    /*
     d("top:         %f %f", CVisibleRect::top().x,          CVisibleRect::top().y           );
     d("rightTop:    %f %f", CVisibleRect::rightTop().x,     CVisibleRect::rightTop().y      );
     d("leftTop:     %f %f", CVisibleRect::leftTop().x,      CVisibleRect::leftTop().y       );
     d("left:        %f %f", CVisibleRect::left().x,         CVisibleRect::left().y          );
     d("right:       %f %f", CVisibleRect::right().x,        CVisibleRect::right().y         );
     d("leftBottom:  %f %f", CVisibleRect::leftBottom().x,   CVisibleRect::leftBottom().y    );
     d("rightBottom: %f %f", CVisibleRect::rightBottom().x,  CVisibleRect::rightBottom().y   );
     d("center:      %f %f", CVisibleRect::center().x,       CVisibleRect::center().y        );
     d("bottom:      %f %f", CVisibleRect::bottom().x,       CVisibleRect::bottom().y        );
     */
#endif

    return true;
}
开发者ID:xoraphics,项目名称:yummyjump,代码行数:101,代码来源:assets.cpp


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