本文整理汇总了C++中setContentScaleFactor函数的典型用法代码示例。如果您正苦于以下问题:C++ setContentScaleFactor函数的具体用法?C++ setContentScaleFactor怎么用?C++ setContentScaleFactor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setContentScaleFactor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create("Pisces");
director->setOpenGLView(glview);
}
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height) {
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height) {
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else {
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
director->runWithScene(scene);
return true;
}
示例2: srand
bool AppDelegate::applicationDidFinishLaunching() {
// load config
auto config = Configuration::getInstance();
config->loadConfigFile("config/words.plist");
// init word data
Constants::initWordData();
// random seed
srand( unsigned( time(0) ) );
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create("My Game");
director->setOpenGLView(glview);
}
auto screenSize = glview->getFrameSize();
auto designSize = Size(320, 480);
std::vector<std::string> searchPaths;
if (screenSize.height > 960)
{
searchPaths.push_back("HDR");
searchPaths.push_back("HD");
searchPaths.push_back("SD");
director->setContentScaleFactor(4.0f);
}
else if (screenSize.height > 480)
{
searchPaths.push_back("HD");
searchPaths.push_back("SD");
director->setContentScaleFactor(2.0f);
}
else
{
searchPaths.push_back("SD");
director->setContentScaleFactor(1.0f);
}
FileUtils::getInstance()->setSearchPaths(searchPaths);
auto cacher = SpriteFrameCache::getInstance();
cacher->addSpriteFramesWithFile("assets.plist");
glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
示例3: Rect
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if (!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || \
(CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || \
(CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect(
"IsoGame",
Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("IsoGame");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width,
designResolutionSize.height,
ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height) {
director->setContentScaleFactor(
MIN(largeResolutionSize.height / designResolutionSize.height,
largeResolutionSize.width / designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height) {
director->setContentScaleFactor(
MIN(mediumResolutionSize.height / designResolutionSize.height,
mediumResolutionSize.width / designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else {
director->setContentScaleFactor(
MIN(smallResolutionSize.height / designResolutionSize.height,
smallResolutionSize.width / designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = tsg::game::GameController::createScene();
// run
director->runWithScene(scene);
return true;
}
示例4: Rect
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("parkour", Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("parkour");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
std::vector<std::string> searchPath;
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// large screens
if (frameSize.height > mediumResolutionSize.height)
{
searchPath.push_back("res-large");
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// medium screens
else if (frameSize.height > smallResolutionSize.height)
{
searchPath.push_back("res-medium");
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// small screens
else
{
searchPath.push_back("res-small");
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
FileUtils::getInstance()->setSearchPaths(searchPath);
register_all_packages();
// create a scene. it's an autorelease object
auto scene = createSceneWithMainMenu();
// run
director->runWithScene(scene);
return true;
}
示例5: if
bool AppDelegate::applicationDidFinishLaunching() {
#ifdef SDKBOX_ENABLED
sdkbox::PluginAdMob::init();
#endif
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("test", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("test");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
auto frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
const char* config = "{\"android\":{\"AdMob\":{\"test\":true,\"ads\":{\"gameover\":{\"type\":\"interstitial\",\"id\":\"ca-app-pub-1329374026572143/1092476511\"},\"home\":{\"width\":300,\"type\":\"banner\",\"id\":\"ca-app-pub-1329374026572143/2685130917\",\"alignment\":\"bottom\",\"height\":50}}}},\"ios\":{\"AdMob\":{\"test\":true,\"ads\":{\"gameover\":{\"type\":\"interstitial\",\"id\":\"ca-app-pub-1329374026572143/4185543717\"},\"home\":{\"width\":300,\"type\":\"banner\",\"id\":\"ca-app-pub-1329374026572143/3847466511\",\"alignment\":\"bottom\",\"height\":50}}}}}";
sdkbox::setInitialConfig(config);
// run
director->runWithScene(scene);
return true;
}
示例6: Rect
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if (!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("oop4", Rect(0, 0, 600, 600));
director->setOpenGLView(glview);
#else
glview = GLViewImpl::create("oop4");
#endif
director->setOpenGLView(glview);
};
//FPS 조절 함수
director->setDisplayStats(true);
director->setAnimationInterval(1.0 / 60);
//////////원하는 크기로 화면 재설정/////////////////
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
//////////////////화면 크기에 맞게 맵을 출력/////////////////////////////
glview->setDesignResolutionSize(375, 375, ResolutionPolicy::NO_BORDER);
register_all_packages();
// create a scene. it's an autorelease object
auto scene = GameScene::createScene();
// run
director->runWithScene(scene);
return true;
}
示例7: printf
void AppDelegate::setupMainScene() {
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
printf("setupMainScene\n");
printf("glview\n");
printf("create\n");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("LasAlitas", Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("LasAlitas");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
//*/
}
示例8: Rect
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || \
(CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || \
(CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("Battle of Stars", Rect(0, 0, developmentResolutionSize.width, developmentResolutionSize.height));
// XXX: Full Screen Here!
// glview = GLViewImpl::createWithFullScreen("ball");
#else
glview = GLViewImpl::create("Battle of Stars");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height) {
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
// if the frame's height is larger than the height of small size.
} else if (frameSize.height > smallResolutionSize.height) {
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
// if the frame's height is smaller than the height of medium size.
} else {
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
FileUtils::getInstance()->addSearchPath("res");
// create a scene. it's an autorelease object
//auto scene = MenuScene::createScene();
auto scene = TransitionFade::create(1.0f, BeginScene::createScene());
// run
director->runWithScene(scene);
return true;
}
示例9: if
bool AppDelegate::applicationDidFinishLaunching() {
sdkbox::PluginGoogleAnalytics::init();
sdkbox::PluginGoogleAnalytics::startSession();
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create("My Game");
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
示例10: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
director->setOpenGLView(glview);
}
glview->setDesignResolutionSize(320, 568, ResolutionPolicy::SHOW_ALL);
director->setContentScaleFactor(1);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
示例11: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create("My Game");
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::FIXED_HEIGHT);
glview->setFrameSize(designResolutionSize.width*2,designResolutionSize.height*2);
director->setContentScaleFactor(0.5f);
register_all_packages();
// create a scene. it's an autorelease object
auto scene = ServerDemo::createScene();
// run
director->runWithScene(scene);
return true;
}
示例12: Rect
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::createWithRect("Assassinate", Rect(0, 0, 960, 640));
director->setOpenGLView(glview);
}
director->getOpenGLView()->setDesignResolutionSize(480, 320, ResolutionPolicy::SHOW_ALL);
static_cast<GLViewImpl*>(glview)->enableRetina(true);
director->setContentScaleFactor(2.0);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
FileUtils::getInstance()->addSearchPath("res");
// create a scene. it's an autorelease object
auto scene = Playground::createScene();
// run
director->runWithScene(scene);
return true;
}
示例13: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
director->setOpenGLView(glview);
}
glview->setFrameSize(360,640);
//glview->setDesignResolutionSize(720 , 1280 , kResolutionShowAll);
glview->setDesignResolutionSize(320.0, 480.0, ResolutionPolicy::FIXED_WIDTH);
std::vector<std::string> searchPath;
searchPath.push_back("w640");
CCFileUtils::getInstance()->setSearchPaths(searchPath);
director->setContentScaleFactor(720.0 / 320.0);
// turn on display FPS
director->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
示例14: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
std::vector<std::string> searchPath;
searchPath.push_back("TileGameResources");
CCFileUtils::getInstance()->setSearchPaths(searchPath);
director->setContentScaleFactor(1.f);
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
示例15: Rect
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::createWithRect("DERPY", Rect(0, 0, 480, 320), 1.0); // Title of window, Rect, Scale of Window to test @2x
director->setOpenGLView(glview);
}
// set sizes for calculating scale in next step
Size designSize = Size(480,320); // game logic size
Size resourceSize = Size(960,640); // resources are this size
// Tell Game's Director to scale assets based on above sizes
director->setContentScaleFactor(resourceSize.height / designSize.height);
director->getOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}