bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. TargetPlatform target = getTargetPlatform();//获取当前设备类型 if (target == kTargetIpad){//如果是Ipad if (pDirector->enableRetinaDisplay(true)){ //如果开启高清视网膜 }else { } } else if (target == kTargetIphone) {//如果是iphone if (pDirector->enableRetinaDisplay(true)) { } else { } } else if (target == kTargetAndroid)//如果是android { } else if (target == kTargetWindows)//如果是Windows { } else if (target == kTargetMacOS)//如果是MacOS { } // turn on display FPS pDirector->setDisplayStats(false); // set FPS. the default value is 1.0/60 if you don't call thisdf pDirector->setAnimationInterval(1.0 / 60); // game init CCScheduler * scheduler = CCDirector::sharedDirector()->getScheduler(); scheduler->scheduleSelector(schedule_selector(AppDelegate::AppUpdate), this, 1.0f/60, false); if( GameControl::RunGameControl() ) { NetMessageManager::GetMessageManager(); } if( SceneManage::GetSceneManageHendle() ) { SceneManage::GetSceneManageHendle()->RunScece( SCENE_LOGIN, false ); } return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); TargetPlatform target = getTargetPlatform(); if (target == kTargetIpad) { // ipad CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); // don't enable retina because we don't have ipad hd resource CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder); } else if (target == kTargetIphone) { // iphone // try to enable retina on device if (true == CCDirector::sharedDirector()->enableRetinaDisplay(true)) { // iphone hd CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); } else { CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone"); } } else { // android, windows, blackberry, linux or mac // use 960*640 resources as design resolution size CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCFileUtils::sharedFileUtils()->setResourceDirectory(""); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(visibleSize.width,visibleSize.height, kResolutionNoBorder); } // turn on display FPS pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 20); // create a scene. it's an autorelease object CCScene *pScene = StartScene::scene(); if (pScene) pDirector->runWithScene(pScene); return true; }
std::string AudioUtils::getFileName(const char* filename) { auto app = Application::getInstance(); auto platform = app->getTargetPlatform(); if (platform == Application::Platform::OS_ANDROID) { return cocos2d::StringUtils::format("%s.ogg", filename); } else if (platform == Application::Platform::OS_IPHONE || platform == Application::Platform::OS_IPAD) { return cocos2d::StringUtils::format("%s.caf", filename); } return filename; }
bool AppDelegate::applicationDidFinishLaunching() { std::vector<std::string> searchPaths; searchPaths.push_back("assets"); // 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("Evil", Rect(0, 0, mediumResolutionSize.width, mediumResolutionSize.height)); #else glview = GLViewImpl::create("Evil"); #endif director->setOpenGLView(glview); } // turn on display FPS //director->setDisplayStats(true); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) Size visibleSize = Director::getInstance()->getVisibleSize(); float height; if (getTargetPlatform() == Platform::OS_IPAD) height = 700; else height = 640; if (visibleSize.height > height) { float s = height / visibleSize.height; glview->setDesignResolutionSize(visibleSize.width*s, height, ResolutionPolicy::NO_BORDER); } #endif // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); FileUtils::getInstance()->setSearchPaths(searchPaths); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("assets.plist"); reloadScene(NULL); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); GameUIController* uic = GameUIController::I(); uic->retain(); TargetPlatform target = getTargetPlatform(); if (target == kTargetIpad){ } else if (target == kTargetIphone){ }else { // android, windows, blackberry, linux or mac // use 960*640 resources as design resolution size uic->loadTuiXML( "tui/tui_iphone4.xml" ); CCFileUtils::sharedFileUtils()->setResourceDirectory("res_iphone"); int w = uic->schemeWidth(); int h = uic->schemeHeight(); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(w, h, kResolutionShowAll); } // turn on display FPS pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object CCScene *pScene = HelloWorld::scene(); // run pDirector->runWithScene(pScene); return true; }
bool AppDelegate::applicationDidFinishLaunching() { /// Add logger CLoggers* logMgr = CLoggers::sharedLoggers(); logMgr->addLogger( this ); //logMgr->setShowTime( false ); // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); CCSize viewSize = CCDirector::sharedDirector()->getWinSizeInPixels(); GLfloat deviceFactor = MAX(viewSize.height, viewSize.width) / 480.f; CCLOG( "Device Factor: %.2f", deviceFactor ); std::string sBuilld = Cocos3d::version(); CCLOG( sBuilld.c_str() ); ////////////////////////////////////////////////////////////////////////// // Use a customized action manager CC3ActionManager::active(); TargetPlatform target = getTargetPlatform(); if (target == kTargetIpad) { // ipad CCFileUtils::sharedFileUtils()->addSearchPath("hd"); // don't enable retina because we don't have ipad hd resource CCEGLView::sharedOpenGLView()->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, kResolutionNoBorder); } else if (target == kTargetIphone) { CCFileUtils::sharedFileUtils()->addSearchPath("sd"); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, kResolutionExactFit); } else { // android, windows, blackberry, linux or mac // use 960*640 resources as design resolution size CCFileUtils::sharedFileUtils()->addSearchPath("sd"); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, kResolutionShowAll); } CCFileUtils::sharedFileUtils()->addSearchPath( "gameui" ); CCFileUtils::sharedFileUtils()->addSearchPath( "3d" ); // turn on display FPS pDirector->setDisplayStats( true ); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval( 1.0f / 60 ); onStartUp(); // create a scene. it's an autorelease object CCScene* pScene = CMainMenu::create(); // run pDirector->runWithScene( pScene ); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLViewImpl::create("My Game"); director->setOpenGLView(glview); } Platform target = getTargetPlatform();//获取当前设备类型 if (target == Platform::OS_IPAD) { auto visibleSizeWidth = 1024; auto visibleSizeHeight = 768; // 根据屏幕尺寸与设计尺寸的比,重新定义设计尺寸(参考kResolutionNum来适配) auto winSize = Director::getInstance()->getWinSize(); //CCSize winSize = CCSizeMake(1136, 640);//CCEGLView::sharedOpenGLView()->getFrameSize(); if (winSize.width/winSize.height > visibleSizeWidth/visibleSizeHeight) { visibleSizeWidth = visibleSizeHeight * winSize.width/winSize.height; } else if (winSize.width/winSize.height < visibleSizeWidth/visibleSizeHeight) { visibleSizeHeight = visibleSizeWidth / (winSize.width/winSize.height); } director->getOpenGLView()->setDesignResolutionSize(visibleSizeWidth, visibleSizeHeight, ResolutionPolicy::NO_BORDER); // ipad //CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); // don't enable retina because we don't have ipad hd resource //director->getOpenGLView()->setDesignResolutionSize(800, 600, ResolutionPolicy::NO_BORDER); } else if (target == Platform::OS_IPHONE) { // 设计尺寸width、height auto visibleSizeWidth = 960; auto visibleSizeHeight = 640; // 根据屏幕尺寸与设计尺寸的比,重新定义设计尺寸(参考kResolutionNum来适配) auto winSize = Director::getInstance()->getWinSize(); //CCSize winSize = CCSizeMake(1136, 640);//CCEGLView::sharedOpenGLView()->getFrameSize(); if (winSize.width/winSize.height > visibleSizeWidth/visibleSizeHeight) { visibleSizeWidth = visibleSizeHeight * winSize.width/winSize.height; } else if (winSize.width/winSize.height < visibleSizeWidth/visibleSizeHeight) { visibleSizeHeight = visibleSizeWidth / (winSize.width/winSize.height); } //CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); //CCSize VisibleSize = CCEGLView::sharedOpenGLView()->getVisibleSize(); director->getOpenGLView()->setDesignResolutionSize(visibleSizeWidth, visibleSizeHeight, ResolutionPolicy::NO_BORDER); } else { auto visibleSizeWidth = 1152; auto visibleSizeHeight = 648; // 根据屏幕尺寸与设计尺寸的比,重新定义设计尺寸(参考kResolutionNum来适配) auto winSize = Director::getInstance()->getWinSize(); //CCSize winSize = CCSizeMake(1136, 640);//CCEGLView::sharedOpenGLView()->getFrameSize(); if (winSize.width/winSize.height > visibleSizeWidth/visibleSizeHeight) { visibleSizeWidth = visibleSizeHeight * winSize.width/winSize.height; } else if (winSize.width/winSize.height < visibleSizeWidth/visibleSizeHeight) { visibleSizeHeight = visibleSizeWidth / (winSize.width/winSize.height); } director->getOpenGLView()->setDesignResolutionSize(visibleSizeWidth, visibleSizeHeight, ResolutionPolicy::NO_BORDER); } // 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); //FileUtils::getInstance()->addSearchPath("pay_center"); // create a scene. it's an autorelease object #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) auto playVidio = PlayVedio::createScene(); HallDataMgr::getInstance()->readConfig(); CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("sound_res/LOAD_BACK.mp3",true); // run director->runWithScene(playVidio); #else auto scene = LoginLayer::createScene(); director->runWithScene(scene); HallDataMgr::getInstance()->readConfig(); CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("sound_res/LOAD_BACK.mp3",true); #endif // auto ploginlayer = static_cast<LoginLayer *>(scene->getChildByTag(10)); // ploginlayer->versionCheck(); return true; }
bool AppDelegate::applicationDidFinishLaunching() { /** * The initialization of StoreController. This is the first and ONLY time it's initialized. **/ cocos2dx_StoreController::initialize("ExampleCustomSecret"); cocos2dx_EventHandlers::getInstance()->addHandler(handler); // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); TargetPlatform target = getTargetPlatform(); if (target == kTargetIpad) { // ipad CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); // don't enable retina because we don't have ipad hd resource CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder); } else if (target == kTargetIphone) { // iphone // if (pDirector->enableRetinaDisplay(true)) // { // iphone hd CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); // } // else // { // CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone"); // } CCEGLView::sharedOpenGLView()->setDesignResolutionSize(720, 1280, kResolutionNoBorder); } else { // android, windows, blackberry, linux or mac // use 960*640 resources as design resolution size CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd"); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(720, 1280, kResolutionNoBorder); } // turn on display FPS pDirector->setDisplayStats(false); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object CCScene *pScene = MainScene::scene(); // run pDirector->runWithScene(pScene); return true; }