void CCGridBase::afterDraw(cocos2d::CCNode *pTarget) { m_pGrabber->afterRender(m_pTexture); // restore projection CCDirector *director = CCDirector::sharedDirector(); director->setProjection(m_directorProjection); if (pTarget->getCamera()->isDirty()) { CCPoint offset = pTarget->getAnchorPointInPoints(); // // XXX: Camera should be applied in the AnchorPoint // kmGLTranslatef(offset.x, offset.y, 0); pTarget->getCamera()->locate(); kmGLTranslatef(-offset.x, -offset.y, 0); } ccGLBindTexture2D(m_pTexture->getName()); // restore projection for default FBO .fixed bug #543 #544 //TODO: CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection()); //TODO: CCDirector::sharedDirector()->applyOrientation(); blit(); }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); // Set the design resolution CCEGLView::sharedOpenGLView()->setDesignResolutionSize(320, 480, 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); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(jsb_register_system); sc->start(); CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if JSB_ENABLE_DEBUGGER ScriptingCore::getInstance()->enableDebugger(); ScriptingCore::getInstance()->runScript("main.debug.js"); #else ScriptingCore::getInstance()->runScript("MoonWarriors-jsb.js"); #endif return true; }
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. // pDirector->enableRetinaDisplay(true); // sets landscape mode //pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait); // turn on display FPS pDirector->setDisplayFPS(false); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); pDirector->setProjection(kCCDirectorProjection2D); // create a scene. it's an autorelease object CCScene *pScene = LogoScene::scene(); // run pDirector->runWithScene(pScene); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); CCSize designSize = CCSizeMake(320, 480); CCSize resourceSize = CCSizeMake(320, 480); if (screenSize.height > 1024) { resourceSize = CCSizeMake(1536, 2048); CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-ipadhd"); } else if (screenSize.height > 960) { resourceSize = CCSizeMake(768, 1536); CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-ipad"); } else if (screenSize.height > 480) { resourceSize = CCSizeMake(640, 960); CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-iphonehd"); } else { CCFileUtils::sharedFileUtils()->setResourceDirectory("resources-iphone"); } pDirector->setContentScaleFactor(resourceSize.height/designSize.height); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.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 / 60); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(jsb_register_system); sc->start(); js_log("RUNNING Main"); CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("main.js"); return true; }
void initViews(CCSize designSize) { (CCScriptEngineManager::sharedManager())->removeScriptEngine(); resetCocosApp(); CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); }
// properties void CCGridBase::setActive(bool bActive) { m_bActive = bActive; if (! bActive) { CCDirector *pDirector = CCDirector::sharedDirector(); ccDirectorProjection proj = pDirector->getProjection(); pDirector->setProjection(proj); } }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine CCLuaEngine *pEngine = CCLuaEngine::defaultEngine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCLuaStack *pStack = pEngine->getLuaStack(); // load framework if (m_projectConfig.isLoadPrecompiledFramework()) { const string precompiledFrameworkPath = SimulatorConfig::sharedDefaults()->getPrecompiledFrameworkPath(); pStack->loadChunksFromZip(precompiledFrameworkPath.c_str()); } // load script string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(m_projectConfig.getScriptFileRealPath().c_str()); size_t pos; while ((pos = path.find_first_of("\\")) != std::string::npos) { path.replace(pos, 1, "/"); } size_t p = path.find_last_of("/\\"); if (p != path.npos) { const string dir = path.substr(0, p); pStack->addSearchPath(dir.c_str()); p = dir.find_last_of("/\\"); if (p != dir.npos) { pStack->addSearchPath(dir.substr(0, p).c_str()); } } string env = "__LUA_STARTUP_FILE__=\""; env.append(path); env.append("\""); pEngine->executeString(env.c_str()); CCLOG("------------------------123------------------------"); CCLOG("LOAD LUA FILE: %s", path.c_str()); CCLOG("------------------------------------------------"); pEngine->executeScriptFile(path.c_str()); return true; }
int CCApplication::run() { IW_CALLSTACK("CCApplication::Run"); s3eBool quitRequested = 0; CCDirector *pDirector = CCDirector::sharedDirector(); struct Evil : CCDirector { using CCDirector::m_pProjectionDelegate; }; (*(Evil*)pDirector).*(&Evil::m_pProjectionDelegate) = this; pDirector->setProjection(kCCDirectorProjectionCustom); if (!applicationDidFinishLaunching() ) { return 0; } uint64 updateTime = 0 ; while (true) { updateTime = s3eTimerGetMs(); s3eDeviceYield(0); s3eKeyboardUpdate(); s3ePointerUpdate(); ccAccelerationUpdate(); quitRequested = s3eDeviceCheckQuitRequest() ; if( quitRequested && CCDirector::sharedDirector()->getOpenGLView() != NULL ) { CCDirector::sharedDirector()->end() ; // end status will be processed in CCDirector::sharedDirector()->mainLoop(); } CCDirector::sharedDirector()->mainLoop(); if( quitRequested ) { break ; } while ((s3eTimerGetMs() - updateTime) < m_nAnimationInterval) { int32 yield = (int32) (m_nAnimationInterval - (s3eTimerGetMs() - updateTime)); if (yield<0) break; s3eDeviceYield(yield); } } return -1; }
void CCRenderTexture::begin() { kmGLMatrixMode(KM_GL_PROJECTION); kmGLPushMatrix(); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); CCDirector *director = CCDirector::sharedDirector(); director->setProjection(director->getProjection()); #if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 kmMat4 modifiedProjection; kmGLGetMatrix(KM_GL_PROJECTION, &modifiedProjection); kmMat4Multiply(&modifiedProjection, CCEGLView::sharedOpenGLView()->getReverseOrientationMatrix(), &modifiedProjection); kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadMatrix(&modifiedProjection); kmGLMatrixMode(KM_GL_MODELVIEW); #endif const CCSize& texSize = m_pTexture->getContentSizeInPixels(); // Calculate the adjustment ratios based on the old and new projections CCSize size = director->getWinSizeInPixels(); float widthRatio = size.width / texSize.width; float heightRatio = size.height / texSize.height; // Adjust the orthographic projection and viewport glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); kmGLMultMatrix(&orthoMatrix); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_nOldFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_uFBO); /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of CCRenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. */ if (CCConfiguration::sharedConfiguration()->checkForGLExtension("GL_QCOM")) { // -- bind a temporary texture so we can clear the render buffer without losing our texture glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTextureCopy->getName(), 0); CHECK_GL_ERROR_DEBUG(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 0); } }
bool AppDelegate::applicationDidFinishLaunching() { if(1){ // permission check MD5Check checker; string binraryPath = "DirectFire"; getAbsoluteResourceFilePath(binraryPath); string resPath = "resfile.dat"; getAbsoluteResourceFilePath(resPath); string dbPath = "db/localsettingdb.sqlit"; getAbsoluteResourceFilePath(dbPath); string binraryMD5 = checker.getFileMD5(binraryPath); string resMD5 = checker.getFileMD5(resPath); string dbMD5 = checker.getFileMD5(dbPath); string localMD5 = checker.genLocalMD5(binraryMD5.append(resMD5).append(dbMD5)); cout << "gen local=" << localMD5 << " get local=" << checker.getLocalMD5() << " gen remote=" << checker.genLocalMD5(binraryMD5.append(resMD5).append(dbMD5)) << endl; // open here when release // if (localMD5.compare(checker.getLocalMD5()) != 0) { // return false; // } ServerInterface::getInstance()->setRemoteMD5(checker.genLocalMD5(binraryMD5.append(resMD5).append(dbMD5))); } // init iap transaction observer IAPHelper::getInstance()->registerListener(ServerInterface::getInstance()); // init net detecter observer NetDetect::getInstance()->registerListener(ServerInterface::getInstance()); // init photo picker PhotoHelper::getInstance()->registerListener(ServerInterface::getInstance()); // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); // use this selection when release CCSize size = CCDirector::sharedDirector()->getWinSize(); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(size.width, size.height, kResolutionShowAll); // turn on display FPS //pDirector->setDisplayStats(true); pDirector->setProjection(kCCDirectorProjection2D); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 30); // run pDirector->runWithScene(SplashScene::create()); return true; }
bool AppDelegate::applicationDidFinishLaunching() { CCDirector* director = CCDirector::sharedDirector(); CCEGLView* EGLView = CCEGLView::sharedOpenGLView(); CCSize screenSize = EGLView->getFrameSize(); director->setOpenGLView(EGLView); director->setContentScaleFactor(designResolutionSize.height / screenSize.height); vector <string> searchPath; searchPath.push_back(resources800x600.directory); CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath); mSharedScreenManager = ScreenManager::create(); Options::SCREEN_WIDTH = designResolutionSize.width; Options::SCREEN_HEIGHT = designResolutionSize.height; Options::SCREEN_CENTER_X = designResolutionSize.width / 2; Options::SCREEN_CENTER_Y = designResolutionSize.height / 2; Options::CAMERA_WIDTH = screenSize.width; Options::CAMERA_HEIGHT = screenSize.height; Options::CAMERA_CENTER_X = screenSize.width / 2; Options::CAMERA_CENTER_Y = screenSize.height / 2; director->setAlphaBlending(false); director->setDepthTest(false); director->setDisplayStats(true); director->setProjection(kCCDirectorProjection2D); director->setAnimationInterval(1.0f / 60.0f); director->runWithScene(Loader::create()); return true; }
void CCRenderTexture::end() { glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO); kmGLPopMatrix(); CCDirector *director = CCDirector::sharedDirector(); CCSize size = director->getWinSizeInPixels(); // restore viewport glViewport(0, 0, GLsizei(size.width * CC_CONTENT_SCALE_FACTOR()), GLsizei(size.height * CC_CONTENT_SCALE_FACTOR())); // special viewport for 3d projection + retina display if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1 ) { glViewport((GLsizei)(-size.width/2), (GLsizei)(-size.height/2), (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR())); } director->setProjection(director->getProjection()); }
//------------------------------------------------------------------------------ bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); #ifdef _WIN32 pDirector->setProjection(kCCDirectorProjection2D); // Set EGLView frame size to *device* w,h float w = WINDOW_ACTUAL_W; float h = WINDOW_ACTUAL_H; CCEGLView::sharedOpenGLView()->setFrameSize(w, h); kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); // New code: rotate to achieve landscape orientation int angle = 0; kmGLRotatef((float)angle, 0, 0, 1); kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, 0, w, 0, h, -1024, 1024 ); kmGLMultMatrix(&orthoMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); #endif // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // OpenQuick stuff InitLuaSystem(); InitLuaMiddleware(); InitLuaApp(); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); CCSize designSize = CCSizeMake(320, 480); CCSize resourceSize = CCSizeMake(640, 960); std::vector<std::string> searchPaths; std::vector<std::string> resDirOrders; TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform(); if (platform == kTargetIphone || platform == kTargetIpad) { searchPaths.push_back("js"); // Resources/Published-iOS searchPaths.push_back("data"); searchPaths.push_back("Published-iOS"); searchPaths.push_back("res"); CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); if (screenSize.height > 480) { resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-iphonehd"); } else { resDirOrders.push_back("resources-iphone"); } CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders); } else if (platform == kTargetAndroid || platform == kTargetWindows) { if(platform == kTargetWindows) { searchPaths.push_back("../../js"); searchPaths.push_back("../../jslib"); searchPaths.push_back("../../data"); searchPaths.push_back("../../AnotherWorld/Published-iOS"); searchPaths.push_back("../../res"); } searchPaths.push_back("AnotherWorldRes"); CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); // Comments it since opengles2.0 only supports texture size within 2048x2048. // if (screenSize.height > 1024) // { // resourceSize = CCSizeMake(1280, 1920); // resDirOrders.push_back("resources-xlarge"); // resDirOrders.push_back(""); // } // else if (screenSize.height > 960) { resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else if (screenSize.height > 480) { resourceSize = CCSizeMake(480, 720); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else { resourceSize = CCSizeMake(320, 568); resDirOrders.push_back("resources-small"); } resDirOrders.push_back("resources-iphone"); CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders); } pDirector->setContentScaleFactor(resourceSize.width/designSize.width); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, 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); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); sc->start(); js_log("RUNNING Main"); CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("app.js"); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine CCLuaEngine *pEngine = CCLuaEngine::defaultEngine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCLuaStack *pStack = pEngine->getLuaStack(); lua_State* L = pStack->getLuaState(); luaopen_MapRuntimeC_luabinding(L); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // load framework // pStack->loadChunksFromZIP("res/framework_precompiled.zip"); // 如果设置了 -e 和 -ek 要加上下面这句 // pStack->setXXTEAKeyAndSign("aaa", 3); // 如果设置了 -e 和 -ek -es 则要加上下面这句 pStack->setXXTEAKeyAndSign("aaa", 3, "XT", 2); // load framework pStack->loadChunksFromZIP("res/script/framework_precompiled.zip"); pStack->loadChunksFromZIP("res/script/game.zip"); pStack->executeString("require 'main'"); // set script path //string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua"); string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua"); #else // load framework if (m_projectConfig.isLoadPrecompiledFramework()) { const string precompiledFrameworkPath = SimulatorConfig::sharedDefaults()->getPrecompiledFrameworkPath(); const string precompiledGamePath = SimulatorConfig::sharedDefaults()->getPrecompiledGamePath(); pStack->setXXTEAKeyAndSign("aaa", 3, "XT", 2);//加密操作 pStack->loadChunksFromZIP(precompiledFrameworkPath.c_str()); pStack->loadChunksFromZIP(precompiledGamePath.c_str()); pStack->executeString("require 'main'"); } // set script path string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(m_projectConfig.getScriptFileRealPath().c_str()); #endif size_t pos; while ((pos = path.find_first_of("\\")) != std::string::npos) { path.replace(pos, 1, "/"); } size_t p = path.find_last_of("/\\"); if (p != path.npos) { const string dir = path.substr(0, p); pStack->addSearchPath(dir.c_str()); p = dir.find_last_of("/\\"); if (p != dir.npos) { pStack->addSearchPath(dir.substr(0, p).c_str()); } } string env = "__LUA_STARTUP_FILE__=\""; env.append(path); env.append("\""); //pEngine->executeString(env.c_str()); CCLOG("==",env.c_str()); CCLOG("------------------------------------------------"); CCLOG("LOAD LUA FILE: %s", path.c_str()); CCLOG("------------------------------------------------"); //pEngine->executeScriptFile(path.c_str()); //pEngine->executeScriptFile("main.lua"); return true; }
void AppDelegate::initGameView() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); if(!isPortraitApp) { screenSize = CCSizeMake(screenSize.height, screenSize.width); } std::vector<std::string> resDirOrders; std::string res; TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform(); if (platform == kTargetIphone || platform == kTargetIpad) { std::vector<std::string> searchPaths = CCFileUtils::sharedFileUtils()->getSearchPaths(); searchPaths.insert(searchPaths.begin(), "Published files iOS"); searchPaths.insert(searchPaths.begin(), getCCBDirectoryPath()); CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); if (screenSize.height > 1136) { res = "iPad"; setResolutionSizes(true, true, isPortraitApp); resDirOrders.push_back("resources-ipadhd"); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); isIPhone = false; isRetina = true; cocos2d::extension::CCBReader::setResolutionScale(2); } else if(screenSize.height > 1024) { res = "iPhone"; setResolutionSizes(false, true, isPortraitApp); resDirOrders.push_back("resources-iphonehd"); resDirOrders.push_back("resources-iphone"); isIPhone = true; isRetina = true; } else if (screenSize.height > 960) { res = "iPad"; setResolutionSizes(true, false, isPortraitApp); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); isIPhone = false; isRetina = false; cocos2d::extension::CCBReader::setResolutionScale(2); } else if (screenSize.height > 480) { res = "iPhone"; setResolutionSizes(false, true, isPortraitApp); resDirOrders.push_back("resources-iphonehd"); resDirOrders.push_back("resources-iphone"); isIPhone = true; isRetina = true; } else { res = "iPhone"; setResolutionSizes(false, false, isPortraitApp); resDirOrders.push_back("resources-iphone"); isIPhone = true; isRetina = false; } } else if (platform == kTargetAndroid || platform == kTargetWindows) { int dpi = -1; dpi = CCDevice::getDPI(); if(dpi > 300) { // retina if (screenSize.height > 1920) { res = "xlarge"; setResolutionSizes(true, true, isPortraitApp); resDirOrders.push_back("resources-xlarge"); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else { res = "large"; setResolutionSizes(false, true, isPortraitApp); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } } else { // non retina if (screenSize.height > 960) { res = "large"; setResolutionSizes(true, false, isPortraitApp); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); cocos2d::extension::CCBReader::setResolutionScale(2); } else if (screenSize.height > 768) { res = "medium"; setResolutionSizes(true, false, isPortraitApp); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else if (screenSize.height > 480) { res = "small"; setResolutionSizes(false, false, isPortraitApp); resDirOrders.push_back("resources-small"); } else { setResolutionSizes(false, false, isPortraitApp); res = "xsmall"; resDirOrders.push_back("resources-xsmall"); } } } CCFileUtils *pFileUtils = CCFileUtils::sharedFileUtils(); pFileUtils->setSearchResolutionsOrder(resDirOrders); std::vector<std::string> searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), pFileUtils->getWritablePath()); pFileUtils->setSearchPaths(searchPaths); PlayerStatus::setDeviceResolution(res); // 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); }
bool AppDelegate::applicationDidFinishLaunching() { //#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS // //Lua版本、JS版本请参考并在lua侧或js侧调用,同时请在该applicationFinishLaunching接口调用dataeye.h中的接口注入接口 // //添加DataEye需要配置的appID和channelId // //APPID 是一组32位的代码,可以在g.dataeye.com创建游戏后获得. // //“937042C1192B1833CD8DF4895B281674”的部分要按照实际情况设置,一定要记得替换哦 // //DC_AFTER_LOGIN模式适用于有账号体系的游戏,后面必须要调用DCAccount login,否则不会上报数据。 // //DEFAULT模式适用于不存在账号体系的游戏(如单机),SDK会用设备ID作为用户的ID // //请选择合适于自己游戏的上报模式 // DCAgent::setReportMode(DC_AFTER_LOGIN); // DCAgent::setDebugMode(true); // DCAgent::onStart("937042C1192B1833CD8DF4895B281674", "DataEye"); //#endif // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); /////.........COPY 3 FILES FIRST. ////////////////// string Srcfile = CCFileUtils::sharedFileUtils()->getSearchPaths()[0] + "res_phone/";//game.dat"; //game.dat string cachePath = CCFileUtils::sharedFileUtils()->getWritablePath() + "res_iphone/"; string lockPath = cachePath + ".lock"; fstream _file; _file.open(lockPath.c_str(),ios::in); CCLog("Srcfile:%s",Srcfile.c_str()); CCLog("cachePath:%s",cachePath.c_str()); CCLog("lockPath:%s",lockPath.c_str()); if (!_file) { if ( CheckDir(cachePath.c_str()) ) { CCLog("create :%s success!",cachePath.c_str()); MyCopyFile(Srcfile + "game.dat",cachePath + "game.dat"); MyCopyFile(Srcfile + "framework_precompiled.zip",cachePath + "framework_precompiled.zip"); ofstream fout; fout.open(cachePath+".lock",ios::app); fout<<" "<<endl; } else { CCLog("create :%s failed!",cachePath.c_str()); } } else { CCLog(".lock exists!"); } // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine CCLuaEngine *pEngine = CCLuaEngine::defaultEngine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCLuaStack *pStack = pEngine->getLuaStack(); #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID lua_State *tolua_s = pStack->getLuaState(); #endif #if defined(ENCRYPT_RESOURCE_ENABLED) && ENCRYPT_RESOURCE_ENABLED == 1 std::string pathBase = "res_phone/"; #else std::string pathBase = "res/"; #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // load framework pathBase = "res_phone/"; std::string pre_zip = "framework_precompiled.zip"; pre_zip = pathBase+pre_zip; CCLog("cpp loadChunksFromZIP begin-- "); pStack->loadChunksFromZIP(pre_zip.c_str()); CCLog("cpp loadChunksFromZIP end-- "); // set script path string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua"); #endif size_t pos; while ((pos = path.find_first_of("\\")) != std::string::npos) { path.replace(pos, 1, "/"); } size_t p = path.find_last_of("/\\"); if (p != path.npos) { const string dir = path.substr(0, p); pStack->addSearchPath(dir.c_str()); p = dir.find_last_of("/\\"); if (p != dir.npos) { pStack->addSearchPath(dir.substr(0, p).c_str()); } } string env = "__LUA_STARTUP_FILE__=\""; env.append(path); env.append("\""); pStack->setXXTEAKeyAndSign("CFgrrwCFewrf", 12); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if 0 std::string rootDir = CCFileUtils::sharedFileUtils()->getWritablePath(); #else std::string rootDir = CCFileUtils::sharedFileUtils()->getWritablePath(); #endif std::string dataPath = cachePath + "game.dat"; CCLog("LOAD MAIN.LUA dataPath=%s",dataPath.c_str()); CCLog("LOAD MAIN.LUA begin--"); bool runCompliedScript = true; ////////////////////////------------------USE COMPILED RESOURCE?? if (runCompliedScript) { if(pStack->loadChunksFromZIP(dataPath.c_str())) { CCLog("LOAD MAIN.LUA end2--"); pEngine->executeString("require \"main\""); CCLog("LOAD MAIN.LUA end3--"); } } else { CCLog("LOAD MAIN.LUA end5--"); pEngine->executeString("print(\"blah\")"); pEngine->executeString("CCLuaLog(\"blah\")"); std::string dataPath = rootDir+pathBase + "scripts/main.lua"; CCLog("dataPath:%s",dataPath.c_str()); if(pStack->executeScriptFile(dataPath.c_str())) { CCLog("LOAD MAIN.LUA end6--"); pEngine->executeString("require \"main\""); } } CCLog("LOAD MAIN.LUA end7--"); pEngine->executeString(env.c_str()); CCLog("LOAD MAIN.LUA end4--"); CCLog("LOAD MAIN.LUA end4--"); #else string dataPath = CCFileUtils::sharedFileUtils()->getWritablePath(); dataPath += "res"DIRECTORY_SEPARATOR"game2.dat"; if(pStack->loadChunksFromZip(dataPath.c_str())) { pEngine->executeString("require \"main\""); } else { CCLOG("------------------------------------------------"); CCLOG("LOAD LUA FILE: %s", path.c_str()); CCLOG("------------------------------------------------"); pEngine->executeScriptFile(path.c_str()); } #endif return true; }
bool AppDelegate::applicationDidFinishLaunching() { //初始化分享 SocialShareAPI::getInstance()->initShareAPI(); // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); CCSize designSize = CCSizeMake(320, 480); CCSize resourceSize = CCSizeMake(320, 480); //对不准了,注意改这个参数 float resizeFactor = 1.0; std::vector<std::string> resDirOrders; ResolutionPolicy resolutionPolicy = kResolutionNoBorder; TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform(); if (platform == kTargetIphone || platform == kTargetIpad) { std::vector<std::string> searchPaths = CCFileUtils::sharedFileUtils()->getSearchPaths(); searchPaths.insert(searchPaths.begin(), "TestCCB"); CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); if (platform == kTargetIphone) { if (screenSize.height > 1136) { designSize = CCSizeMake(384, 512); resourceSize = CCSizeMake(1536, 2048); resDirOrders.push_back("resources-ipadhd"); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); resizeFactor = 4.0; } else if (screenSize.height > 1024) { designSize = CCSizeMake(320, 568); resourceSize = CCSizeMake(640, 1136); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); resizeFactor = 2.0; } else if (screenSize.height > 960) { designSize = CCSizeMake(384, 512); resourceSize = CCSizeMake(768, 1024); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); resizeFactor = 2.0; } else if (screenSize.height > 480) { designSize = CCSizeMake(320, 480); resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-iphonehd"); resDirOrders.push_back("resources-iphone"); resizeFactor = 2.0; } else { designSize = CCSizeMake(320, 480); resourceSize = CCSizeMake(320, 480); resDirOrders.push_back("resources-iphonehd"); resDirOrders.push_back("resources-iphone"); resizeFactor = 2.0; } } else { // for iPad, Just Scale Up designSize = CCSizeMake(320, 426); resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-iphonehd"); resDirOrders.push_back("resources-iphone"); resizeFactor = resourceSize.width/designSize.width; } resolutionPolicy = kResolutionNoBorder; } else if (platform == kTargetAndroid || platform == kTargetWindows) { #if 0 if (screenSize.height > 960) { resourceSize = CCSizeMake(1280, 1920); resDirOrders.push_back("resources-xlarge"); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else if (screenSize.height > 720) { resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else if (screenSize.height > 480) { resourceSize = CCSizeMake(480, 720); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else { resourceSize = CCSizeMake(320, 480); resDirOrders.push_back("resources-small"); } #endif if (screenSize.height > 720) { if(screenSize.height / screenSize.width >= 1136/640) { resourceSize = CCSizeMake(640, 1136); } else { resourceSize = CCSizeMake(640, 960); } resDirOrders.push_back("resources-large"); //resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); m_Helper.androidResourceType = kCPreloadHelperAndroidResourceTypeLarge; } else { if(screenSize.height / screenSize.width >= 568/320) { resourceSize = CCSizeMake(320, 568); } else { resourceSize = CCSizeMake(320, 480); } resDirOrders.push_back("resources-small"); m_Helper.androidResourceType = kCPreloadHelperAndroidResourceTypeSmall; } resolutionPolicy = kResolutionFixedWidth; resizeFactor = resourceSize.width/designSize.width; //designSize.height = designSize.width * resourceSize.height / resourceSize.width; designSize.height = designSize.width * screenSize.height / screenSize.width; } CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders); //pDirector->setContentScaleFactor(resourceSize.width/designSize.width); pDirector->setContentScaleFactor(resizeFactor); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) m_Helper.Preload(); #endif CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); // turn on display FPS pDirector->setDisplayStats(false);//pDirector->setDisplayStats(true);// // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); sc->addRegisterCallback(MinXmlHttpRequest::_js_register); sc->addRegisterCallback(js_OfferWallController::_js_register); sc->addRegisterCallback(register_all_jsb_SocialShareAPI); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) sc->addRegisterCallback(register_all_jsb_iOSiapWrapper); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #endif /*CC_TARGET_PLATFORM*/ sc->addRegisterCallback(CommonFunction::_js_register); // 初始化友盟统计 CStat* pStat = CStat::GetInstance(); pStat->Init(); sc->addRegisterCallback(CStatParam::_js_register); sc->addRegisterCallback(CStat::_js_register); sc->start(); CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); ResetCoin(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) initChannel(); #endif /*CC_TARGET_PLATFORM*/ ScriptingCore::getInstance()->runScript("main.js"); //ScriptingCore::getInstance()->runScript("hello.js"); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) m_Helper.load(); #endif pStat->logTimedEventBegin("runtime"); // //testUnzipFiles(); //UInt32 category = AVAudioSessionCategoryPlayAndRecord; //AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category); //UInt32 route = kAudioSessionOverrideAudioRoute_None; //AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(route), &route); SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.8); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) CommonFunction_Notify_Splash_Fade(); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) m_pKeypadDelegate = new CCMyKeypadDelegate(); if ( pDirector->getKeypadDispatcher() != NULL ) { pDirector->getKeypadDispatcher()->addDelegate(m_pKeypadDelegate); } #endif return true; }
bool AppDelegate::applicationDidFinishLaunching() {// initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize(); CCSize designSize = CCSizeMake(480, 320); CCSize resourceSize = CCSizeMake(480, 320); std::vector<std::string> resDirOrders; TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform(); if (platform == kTargetIphone || platform == kTargetIpad) { std::vector<std::string> searchPaths = CCFileUtils::sharedFileUtils()->getSearchPaths(); searchPaths.insert(searchPaths.begin(), "Published files iOS"); CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); if (screenSize.height > 1024) { resourceSize = CCSizeMake(1536, 2048); resDirOrders.push_back("resources-ipadhd"); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); } else if (screenSize.height > 960) { resourceSize = CCSizeMake(768, 1024); resDirOrders.push_back("resources-ipad"); resDirOrders.push_back("resources-iphonehd"); } else if (screenSize.height > 480) { resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-iphonehd"); resDirOrders.push_back("resources-iphone"); } else { resourceSize = CCSizeMake(320, 480); resDirOrders.push_back("resources-iphone"); } } else if (platform == kTargetAndroid || platform == kTargetWindows) { if (screenSize.height > 960) { resourceSize = CCSizeMake(1280, 1920); resDirOrders.push_back("resources-xlarge"); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else if (screenSize.height > 720) { resourceSize = CCSizeMake(640, 960); resDirOrders.push_back("resources-large"); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else if (screenSize.height > 480) { resourceSize = CCSizeMake(480, 720); resDirOrders.push_back("resources-medium"); resDirOrders.push_back("resources-small"); } else { resourceSize = CCSizeMake(480, 320); resDirOrders.push_back("iphone"); resDirOrders.push_back("resources-small"); } } CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders); pDirector->setContentScaleFactor(resourceSize.width/designSize.width); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.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 / 60); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); sc->addRegisterCallback(MinXmlHttpRequest::_js_register); sc->addRegisterCallback(register_jsb_websocket); sc->start(); CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("main.js"); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); pDirector->setProjection(kCCDirectorProjection2D); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine CCLuaEngine *pEngine = CCLuaEngine::defaultEngine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); CCLuaStack *pStack = pEngine->getLuaStack(); lua_State* L = pStack->getLuaState(); // load lua extensions luaopen_lua_extensions(L); // load cocos2dx_extensions luabinding luaopen_cocos2dx_extensions_luabinding(L); // load cocos2dx_extra luabinding luaopen_cocos2dx_extra_luabinding(L); // load precompiled framework luaopen_framework_precompiled(L); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua"); #else string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(getStartupScriptFilename().c_str()); #endif int pos; while ((pos = path.find_first_of("\\")) != std::string::npos) { path.replace(pos, 1, "/"); } size_t p = path.find_last_of("/\\"); if (p != path.npos) { const string dir = path.substr(0, p); pStack->addSearchPath(dir.c_str()); p = dir.find_last_of("/\\"); if (p != dir.npos) { pStack->addSearchPath(dir.substr(0, p).c_str()); } } string env = "__LUA_STARTUP_FILE__=\""; env.append(path); env.append("\""); pEngine->executeString(env.c_str()); CCLOG("------------------------------------------------"); CCLOG("LOAD LUA FILE: %s", path.c_str()); CCLOG("------------------------------------------------"); pEngine->executeScriptFile(path.c_str()); return true; }
bool AppDelegate::applicationDidFinishLaunching() { CCDirector* director = CCDirector::sharedDirector(); CCEGLView* EGLView = CCEGLView::sharedOpenGLView(); CCSize screenSize = EGLView->getFrameSize(); #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID soomla::CCSoomla::sharedSoomla()->addEventHandler(handler); InAppPurchasesList *assets = InAppPurchasesList::create(); CCDictionary *storeParams = CCDictionary::create(); storeParams->setObject(CCString::create(Options::SOOMLA_BASE_64_KEY), "soomSec"); #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID storeParams->setObject(CCString::create(Options::GOOGLE_PLAY_BASE_64_KEY), "androidPublicKey"); #endif storeParams->setObject(CCString::create(Options::SOOMLA_CUSTOM_BASE_64_KEY), "customSecret"); #if COCOS2D_DEBUG >= 1 && CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID storeParams->setObject(CCBool::create(true), "androidTestMode"); #endif soomla::CCStoreController::createShared(assets, storeParams); #endif #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS if(screenSize.width >= 2048) { Options::designResolutionSize = CCSizeMake(1920, 1280); } else { Options::designResolutionSize = CCSizeMake(720, 1280); } #elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID //Options::designResolutionSize = CCSizeMake(270, 480); Options::designResolutionSize = CCSizeMake(720, 1280); #elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT Options::designResolutionSize = CCSizeMake(1920, 1280); #else Options::designResolutionSize = CCSizeMake(720, 1280); #endif director->setOpenGLView(EGLView); director->setContentScaleFactor(Options::designResolutionSize.height / screenSize.height); Options::SCREEN_WIDTH = Options::designResolutionSize.width; Options::SCREEN_HEIGHT = Options::designResolutionSize.height; Options::SCREEN_CENTER_X = Options::designResolutionSize.width / 2; Options::SCREEN_CENTER_Y = Options::designResolutionSize.height / 2; Options::CAMERA_WIDTH = screenSize.width; Options::CAMERA_HEIGHT = screenSize.height; Options::CAMERA_CENTER_X = screenSize.width / 2; Options::CAMERA_CENTER_Y = screenSize.height / 2; vector <string> searchPath; #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS { if(Options::CAMERA_WIDTH >= 2048) { searchPath.push_back(resources2048x1536.directory); Options::DEVICE_TYPE = Options::DEVICE_TYPE_IPAD_RETINA; } else { if(Options::CAMERA_HEIGHT == 960) { searchPath.push_back(resources1280x720xPVRTC2.directory); Options::DEVICE_TYPE = Options::DEVICE_TYPE_IPHONE4; if(AppDelegate::IS_IPOD) { Options::DEVICE_TYPE = Options::DEVICE_TYPE_IPOD4; } } else { searchPath.push_back(resources1280x720.directory); Options::DEVICE_TYPE = Options::DEVICE_TYPE_IPHONE5; } } } #elif CC_TARGET_PLATFORM == CC_PLATFORM_MAC searchPath.push_back(resources1920x1080.directory); Options::DEVICE_TYPE = Options::DEVICE_TYPE_MAC; #elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID if(Options::CAMERA_HEIGHT == 1184) { Options::DEVICE_TYPE = Options::DEVICE_TYPE_NEXUS3; searchPath.push_back(resources1280x720.directory); } else if(Options::CAMERA_HEIGHT < 720) { Options::DEVICE_TYPE = Options::DEVICE_TYPE_IPHONE5; searchPath.push_back(resources480x320.directory); } else { Options::DEVICE_TYPE = Options::DEVICE_TYPE_IPHONE5; searchPath.push_back(resources1280x720.directory); } #elif CC_TARGET_PLATFORM == CC_PLATFORM_WP8 searchPath.push_back(resources1280x720.directory); Options::DEVICE_TYPE = Options::DEVICE_TYPE_MAC; #else Options::DEVICE_TYPE = Options::DEVICE_TYPE_WINDOWS; searchPath.push_back(resources1920x1080.directory); #endif CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath); director->setDisplayStats(false); director->setProjection(kCCDirectorProjection2D); director->setAnimationInterval(1.0f / 60.0f); if(!AppDelegate::isInstalled() || AppDelegate::lastVersion() != Options::VERSION) { AppDelegate::install(false); // NOT SOFT INSTALLATION } Options::init(); Screen* pScene = SplashScreen::create(); director->runWithScene(pScene); return true; }