#include "AppDelegate.h" #include "ServiceManager.h" #include "GameManager.h" #include "MainScene.h" #include "UpgradeScene.h" #include "LoadingScene.h" #include "LogoScene.h" #include "GameScene.h" #include "IntroScene.h" USING_NS_CC; AppDelegate::AppDelegate() { } AppDelegate::~AppDelegate() { } // if you want a different context, modify the value of glContextAttrs // it will affect all platforms void AppDelegate::initGLContextAttrs() { // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount GLContextAttrs glContextAttrs = { 8, 8, 8, 8, 24, 8 ,0}; GLView::setGLContextAttrs(glContextAttrs); } // if you want to use the package manager to install more packages, // don't modify or remove this function static int register_all_packages() { return 0; //flag for packages manager } bool AppDelegate::applicationDidFinishLaunching() { auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if (!glview) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) glview = GLViewImpl::createWithRect("Feathery Fighters", Rect(0, 0, 1536.f, 864.f)); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) //glview = GLViewImpl::createWithFullScreen("Feathery Fighters"); glview = GLViewImpl::createWithRect("Feathery Fighters", Rect(0, 0, 1536.f, 864.f)); #else glview = GLViewImpl::create("Feathery Fighters"); #endif director->setOpenGLView(glview); } // just for debug #if COCOS2D_DEBUG // turn on display FPS director->setDisplayStats(true); #endif // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0f/60.0f); // Set the design resolution glview->setDesignResolutionSize(2048, 1152, ResolutionPolicy::FIXED_WIDTH); // create GameManager instance here. (or loading scene!) // initial sdkbox for ChartBoost #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #else #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) //init the searchpath vector std::vector searchPaths; //save & load or levels files , i mean json files go here. searchPaths.push_back("files"); searchPaths.push_back("files/physics"); //audio files must be placed in the audio folder searchPaths.push_back("music"); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) searchPaths.push_back("sfx_wav"); #else searchPaths.push_back("sfx_ogg"); #endif //font files must be placed in the fonts folder searchPaths.push_back("fonts"); // choose between hd and sd Size frameSize = glview->getFrameSize(); //TODO remove this if at the end //#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // // // //#else if (frameSize.width >= 1900.f) { searchPaths.push_back("hdr/foreground_hud"); searchPaths.push_back("hdr/entities_stuff_over"); searchPaths.push_back("hdr/entities_enemies"); searchPaths.push_back("hdr/entities_spine_stuff"); searchPaths.push_back("hdr/player_over"); searchPaths.push_back("hdr/player_tookans"); searchPaths.push_back("hdr/background"); searchPaths.push_back("hdr/etc"); searchPaths.push_back("hdr/etc/etc"); } else { searchPaths.push_back("hd/foreground_hud"); searchPaths.push_back("hd/entities_stuff_over"); searchPaths.push_back("hd/entities_enemies"); searchPaths.push_back("hd/entities_spine_stuff"); searchPaths.push_back("hd/player_over"); searchPaths.push_back("hd/player_tookans"); searchPaths.push_back("hd/background"); searchPaths.push_back("hd/etc"); searchPaths.push_back("hd/etc/etc"); director->setContentScaleFactor(0.5f); } cocos2d::FileUtils::getInstance()->setSearchPaths(searchPaths); ServiceManager::getInstance(); GameManager::getInstance(); //#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) //here we add the searchpath vector(array) to FileUtils // create game manager instance for the first time ServiceManager::getInstance(); //gm->loadSQLGameData(); //// create a scene. it's an autorelease object Scene* scene; if (!TEST_MODE) { //Logo Scene //scene = LogoScene::createScene(); //////Game Scene //scene = GameScene::createScene(); ////main scene scene = MainScene::createScene(); ////Intro Scene //scene = IntroScene::createScene(); ////Upgrade Scene //scene = UpgradeScene::createScene(); } else { //////Game Scene //scene = GameScene::createScene(); ////Intro Scene //scene = IntroScene::createScene(); ////Loading Scene //scene = LoadingScene::createScene(); ////Upgrade Scene //scene = UpgradeScene::createScene(); //main scene scene = MainScene::createScene(); ////purchase scene //scene = PurchaseScene::createScene(); } // run with the scene director->runWithScene(scene); return true; } // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { SQM->save(GM->mySQLGameData.coins); ServiceManager::getInstance()->audioManager->pauseAll(); Director::getInstance()->stopAnimation(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { ServiceManager::getInstance()->audioManager->resumeAll(); Director::getInstance()->startAnimation(); }