bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    
    pDirector->setOpenGLView(pEGLView);
    
    CCSize screenSize = pEGLView->getFrameSize();
    CCSize designSize = CCSize(2048, 1536);
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionExactFit);
    
    if (screenSize.height > 768) {
        pDirector->setContentScaleFactor(1536/designSize.height);
    } else if (screenSize.height > 320) {
        pDirector->setContentScaleFactor(768/designSize.height);
    } else {
        pDirector->setContentScaleFactor(380/designSize.height);
    }

    // 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 = GameLayer::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 2
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
	
	srand(time(NULL));

    pDirector->setOpenGLView(pEGLView);

    // Set the design resolution
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

	CCSize frameSize = pEGLView->getFrameSize();
    
    vector<string> searchPath;

    // In this demo, we select resource according to the frame's height.
    // If the resource size is different from design resolution size, you need to set contentScaleFactor.
    // We use the ratio of resource's height to the height of design resolution,
    // this can make sure that the resource's height could fit for the height of design resolution.

    // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height > mediumResource.size.height)
	{
        searchPath.push_back(largeResource.directory);

        pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
	}
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height)
    {
        searchPath.push_back(mediumResource.directory);
        
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
	else
    {
        searchPath.push_back(smallResource.directory);

        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    
    // set searching path
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
	
    // 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 = TicTacToeScene::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // デザインサイズの設定
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

    CCSize frameSize = pEGLView->getFrameSize();

    std::vector<std::string> searchPath;

    if (frameSize.height > largeResource.size.height)
    {
        // iPad Retina用リソースを使用
        searchPath.push_back(xlargeResource.directory);
        pDirector->setContentScaleFactor(MIN(xlargeResource.size.height / designResolutionSize.height, xlargeResource.size.width / designResolutionSize.width));
    }
    else if (frameSize.height > smallResource.size.height)
    {
        // iPad用リソースを使用
        searchPath.push_back(largeResource.directory);
        pDirector->setContentScaleFactor(MIN(largeResource.size.height / designResolutionSize.height, largeResource.size.width / designResolutionSize.width));
    }
    else
    {
        // iPhone用リソースを使用
        searchPath.push_back(smallResource.directory);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height / designResolutionSize.height, smallResource.size.width / designResolutionSize.width));
    }

    // リソースディレクトリを指定
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);

    // 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);

    // CocosBuilderのファイルを読み込みゲーム画面を生成する
    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    ccNodeLoaderLibrary->registerCCNodeLoader("GameLayer", GameLayerLoader::loader());
    CCBReader* ccbReader = new CCBReader(ccNodeLoaderLibrary);
    CCNode* node = ccbReader->readNodeGraphFromFile("GameLayer.ccbi");
    ((GameLayer*)node)->setAnimationManager(ccbReader->getAnimationManager());

    // シーンを用意し、ゲーム画面を設置する
    CCScene* pScene = CCScene::create();
    if (node != NULL)
        pScene->addChild(node);
    ccbReader->release();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 4
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    pDirector->setOpenGLView(pEGLView);


    CCSize frameSize = pEGLView->getFrameSize();

    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionExactFit);

    if (frameSize.height > mediumResource.size.height)
    {
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height)
    {
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
    else
    {
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }


    // 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);

    // register lua engine
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);

    CCLuaStack *pStack = pEngine->getLuaStack();
    lua_State *tolua_s = pStack->getLuaState();
    tolua_extensions_ccb_open(tolua_s);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    pStack = pEngine->getLuaStack();
    tolua_s = pStack->getLuaState();
    tolua_web_socket_open(tolua_s);
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
    CCFileUtils::sharedFileUtils()->addSearchPath("script");
#endif

    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
    pEngine->addSearchPath(path.substr(0, path.find_last_of('/')).c_str());
    pEngine->executeScriptFile(path.c_str());

    return true;
}
Ejemplo n.º 5
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();

    //default
    //CCSize designSize = CCSizeMake(480, 320);
    CCSize designSize = CCSizeMake(450, 680);
    
    std::vector<std::string> searchPaths;
    
    //TODO create the different image resolutions
    if (screenSize.height > designSize.height)
    {
    	CCLOG("using high res sd");
        searchPaths.push_back("hd");
        searchPaths.push_back("sd");
        pDirector->setContentScaleFactor(designSize.height/640.0f);

    }
    else
    {
    	CCLOG("using low res sd");
        searchPaths.push_back("sd");
        pDirector->setContentScaleFactor(designSize.height/640.0f);
    }
    
    CCLOG("screen size %f x %f", screenSize.width, screenSize.height);

    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
#else
	CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
#endif

    // 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 / 40);

    CCScene *pScene;
    
    if(cocos2d::CCUserDefault::sharedUserDefault()->getStringForKey("username") == "") {
        //create a scene. it's an autorelease object
        pScene = IntroScene::create();
    } else {
        pScene = GameLayer::scene();
    }
    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 6
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
	//pEGLView->set(1024,768);
    pDirector->setOpenGLView(pEGLView);

    // Set the design resolution
    //pEGLView->setDesignResolutionSize(320,480, kResolutionShowAll);
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(320, 480, kResolutionNoBorder);

	CCSize frameSize = pEGLView->getFrameSize();

    // In this demo, we select resource according to the frame's height.
    // If the resource size is different from design resolution size, you need to set contentScaleFactor.
    // We use the ratio of resource's height to the height of design resolution,
    // this can make sure that the resource's height could fit for the height of design resolution.
#if 0
    // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height > mediumResource.size.height)
	{ 
		CCFileUtils::sharedFileUtils()->setResourceDirectory(largeResource.directory);
        pDirector->setContentScaleFactor(largeResource.size.height/designResolutionSize.height);
	}
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height)
    { 
        CCFileUtils::sharedFileUtils()->setResourceDirectory(mediumResource.directory);
        pDirector->setContentScaleFactor(mediumResource.size.height/designResolutionSize.height);
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
	else
    { 
		CCFileUtils::sharedFileUtils()->setResourceDirectory(smallResource.directory);
        pDirector->setContentScaleFactor(smallResource.size.height/designResolutionSize.height);
    }
#else
		CCFileUtils::sharedFileUtils()->setResourceDirectory(winResource.directory);
        //pDirector->setContentScaleFactor(largeResource.size.height/designResolutionSize.height);
#endif
    // 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();
	
	CCScene *pScene = SysMenu::scene();
    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 7
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    
    pDirector->setOpenGLView(pEGLView);
    
    CCSize screenSize = pEGLView->getFrameSize();
    CCSize designSize = CCSize(2048, 1536);
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionExactFit);
	std::vector<std::string> searchPaths;

    if (screenSize.height > 768) {
		searchPaths.push_back("ipadhd");
		CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
        pDirector->setContentScaleFactor(1536/designSize.height);
    } else if (screenSize.height > 320) {
		searchPaths.push_back("ipad");
		CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
        pDirector->setContentScaleFactor(768/designSize.height);
    } else {
		searchPaths.push_back("iphone");
		CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
        pDirector->setContentScaleFactor(380/designSize.height);
    }
    
	SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3").c_str());
	SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("falling.wav").c_str());
	SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("hitBuilding.wav").c_str());
	SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("jump.wav").c_str());
	SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("crashing.wav").c_str());
	SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("start.wav").c_str());
	SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("openUmbrella.wav").c_str());
    
    SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5f);
    SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.5f);
    
    
    // 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 = GameLayer::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 8
0
/**
 * Setup the screen resolution acoording to the device.
 * Set the resources search directory.
 */
void FWGame::setupScreenResolution()
{
    CCDirector *pDirector = CCDirector::sharedDirector();
    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
    std::vector<std::string> searchPaths;
    
    // Set
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)     // iOS platform
    
    if (m_device->isIPhoneRetina())
    {
        CCLOG("is iphone retina.");
        //3.5-inch
        searchPaths.push_back("./images/iphonehd");  //Resources/Published-iOS/resources-iphonehd
        
        CCEGLView::sharedOpenGLView()->setDesignResolutionSize(FWD_IPHONE_LANDSCAPE_WIDTH,
                                                               FWD_IPHONE_LANDSCAPE_HEIGHT,
                                                               kResolutionNoBorder);
        pDirector->setContentScaleFactor(2.0f);         //2倍のスケールサイズ
    }
    else if (m_device->isIPhone5()) // 4-inch
    {
        CCLOG("is iphone 5.");
        searchPaths.push_back("./images/iphonehd");  //Resources/Published-iOS/resources-iphonehd
        
        
        CCEGLView::sharedOpenGLView()->setDesignResolutionSize(FWD_IPHONE5_LANDSCAPE_WIDTH,
                                                               FWD_IPHONE_LANDSCAPE_HEIGHT,
                                                               kResolutionNoBorder);
        pDirector->setContentScaleFactor(2.f);         //2倍のスケールサイズ
    }
    else if (m_device->isIPhone())
    {
        CCLOG("is iphone3GS.");
        searchPaths.push_back("./images/iphone");  //Resources/Published-iOS/resources-iphone
        
        CCEGLView::sharedOpenGLView()->setDesignResolutionSize(FWD_IPHONE_LANDSCAPE_WIDTH,
                                                               FWD_IPHONE_LANDSCAPE_HEIGHT,
                                                               kResolutionNoBorder);
        pDirector->setContentScaleFactor(1.0f);
    }

#else        // Other plateform. (Android...)

    searchPaths.push_back("./images"); // Resources/Published-iOS
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(FWD_IPHONE_LANDSCAPE_WIDTH,
                                                           FWD_IPHONE_LANDSCAPE_HEIGHT,
                                                           kResolutionExactFit);

#endif
    // About search path, please check: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Mechanism_of_loading_resources
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
}
Ejemplo n.º 9
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // デザインサイズの設定
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
    
    CCSize frameSize = pEGLView->getFrameSize();
    
    std::vector<std::string> searchPath;
    
    if (frameSize.height > mediumResource.size.height)
    {
        // [L]ディレクトリのソースを使用
        searchPath.push_back(largeResource.directory);
        pDirector->setContentScaleFactor(MIN(largeResource.size.height / designResolutionSize.height, largeResource.size.width / designResolutionSize.width));
    }
    else if (frameSize.height > smallResource.size.height)
    {
        // [M]ディレクトリのリソースを使用
        searchPath.push_back(mediumResource.directory);
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height / designResolutionSize.height, mediumResource.size.width / designResolutionSize.width));
    }
    else
    {
        // [S]ディレクトリのリソースを使用
        searchPath.push_back(smallResource.directory);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height / designResolutionSize.height, smallResource.size.width / designResolutionSize.width));
    }
    
    // リソースディレクトリを指定
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
    
    // turn on display FPS for debug
    //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 = TitleScene::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
    
    CCSize designSize = CCSizeMake(480, 320);
    
    if (screenSize.height > 320)
    {
        CCSize resourceSize = CCSizeMake(960, 640);
        CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
        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);

    CCScene * pScene = CCScene::create();
    CCLayer * pLayer = new TestController();
    pLayer->autorelease();

    pScene->addChild(pLayer);
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 11
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    
    pDirector->setOpenGLView(pEGLView);
    
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
    CCSize framSize = pEGLView->getFrameSize();
    
    
    CCFileUtils::sharedFileUtils()->setResourceDirectory(hongMiResource.directory);
	CCString mm;
	mm = CCFileUtils::sharedFileUtils()->getResourceDirectory();

	CCLOG("curent URL: %s", mm);

    pDirector->setContentScaleFactor(hongMiResource.size.width/designResolutionSize.width);
    

    // 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 =  new LoadingScene();//TestLayer::scene();//
    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 12
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

	CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
	//pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
	pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

	//set ScaleFactor
	pDirector->setContentScaleFactor( 640 / designResolutionSize.width);

    // 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);

    // register lua engine
    //CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    //CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);

    //std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
    //pEngine->executeScriptFile(path.c_str());

	View::_gamemanager::instance()->DisplayNowScene(View::SCENE_INIT);


    return true;
}
Ejemplo n.º 13
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
	    //FIXED_WIDTH
	pEGLView->setDesignResolutionSize(320, 480 , ResolutionPolicy::kResolutionShowAll);
    std::vector<std::string> searchPath;
    searchPath.push_back("image");
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
    pDirector->setContentScaleFactor(640 / 320);

    // 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
	auto pScene = PlayLayer::CreatScene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 14
0
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;
}
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    //Fit screen of any size
    pEGLView->setDesignResolutionSize(320, 480, kResolutionExactFit);
    pDirector->setContentScaleFactor(1);
    
    
    // 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 = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 16
0
bool AppDelegate::applicationDidFinishLaunching() 
{
    //Initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

	pDirector->setContentScaleFactor(1);
	CCEGLView::sharedOpenGLView()->setDesignResolutionSize(768, 1280, 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 = StartScene::scene();

    // run
    pDirector->runWithScene(pScene);
	
    return true;
}
Ejemplo n.º 17
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // 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);
    
    //
    CCSize frameSize = pEGLView->getFrameSize();
    CCLOG("applicationDidFinishLaunching frameSize.width = %f  frameSize.height= %f", frameSize.width,frameSize.height);
    if(frameSize.height/frameSize.width>1.4){
        pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionFixedWidth);
    } else {
        pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionFixedHeight);
    }
    
    if(designResolutionSize.width == 720){
        pDirector->setContentScaleFactor( smallResource_tate2.size.width / designResolutionSize.width );    //ч╕ж
    } else {
        pDirector->setContentScaleFactor( smallResource_yoko.size.width / designResolutionSize.width );    //цик
    }
    
    cocos2d::CCSize visibleSize = cocos2d::CCDirector::sharedDirector()->getVisibleSize();
    cocos2d::CCPoint origin = cocos2d::CCDirector::sharedDirector()->getVisibleOrigin();
    
    CCLOG("applicationDidFinishLaunching designResolutionSize.width = %f ", designResolutionSize.width);
    CCLOG("applicationDidFinishLaunching designResolutionSize.height = %f ", designResolutionSize.height);
    CCLOG("applicationDidFinishLaunching pDirector->getContentScaleFactor() = %f ", pDirector->getContentScaleFactor() );
    CCLOG("applicationDidFinishLaunching visibleSize  width=%f height=%f ", visibleSize.width, visibleSize.height );
    CCLOG("applicationDidFinishLaunching origin  x=%f y=%f ", origin.x, origin.y );

    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();
    //CCScene *pScene = HelloWorld2::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 18
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    CCEGLView::sharedOpenGLView()->setFrameSize(1280, 720);
#endif
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
    CCSize designSize = CCSizeMake(480, 320);
    std::vector<std::string> searchPaths;

    if (screenSize.height > 320)
    {
        CCSize resourceSize = CCSizeMake(960, 640);
        searchPaths.push_back("hd");
        searchPaths.push_back("sd");
//		searchPaths.push_back("fonts");
        pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
    }
    else
    {
        searchPaths.push_back("sd");
        pDirector->setContentScaleFactor(320.0f/designSize.height);
    }
    
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, 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
    GameMenuScene *gameMenuScene = GameMenuScene::create();

    // run
    pDirector->runWithScene(gameMenuScene);

    return true;
}
Ejemplo n.º 19
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(768, 1024, kResolutionExactFit);
    
    std::vector<std::string> resVec;
  
    
    if (screenSize.width > 768)
    {
        resVec.push_back("hd");
        resVec.push_back("sd");
        CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resVec);
        pDirector->setContentScaleFactor(2);
    }
    else
    {
        resVec.push_back("sd");
        resVec.push_back("hd");
        CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resVec);
        pDirector->setContentScaleFactor(1);
    }
    
    SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("hit.wav").c_str());
    SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("score.wav").c_str());


    // 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 = GameLayer::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 20
0
bool AppDelegate::applicationDidFinishLaunching() {
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

    // デザインサイズの設定
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

    CCSize frameSize = pEGLView->getFrameSize();

    std::vector<std::string> searchPath;

    if (frameSize.height > mediumResource.size.height)
    {
        // Lディレクトリのリソースを使用
        searchPath.push_back(largeResource.directory);
        pDirector->setContentScaleFactor(MIN(largeResource.size.height / designResolutionSize.height, largeResource.size.width / designResolutionSize.width));
    }
    else if (frameSize.height > smallResource.size.height)
    {
        // Mディレクトリのリソースを使用
        searchPath.push_back(mediumResource.directory);
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height / designResolutionSize.height, mediumResource.size.width / designResolutionSize.width));
    }
    else
    {
        // Sディレクトリのリソースを使用
        searchPath.push_back(smallResource.directory);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height / designResolutionSize.height, smallResource.size.width / designResolutionSize.width));
    }

    // リソースディレクトリを指定
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
    pDirector->setDisplayStats(true);
    pDirector->setAnimationInterval(1.0 / 60);

    CCScene* pScene = GameScene::scene();
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 21
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

    CCSize screenSize = pDirector->getWinSize();

    //set design screen size to the iPad and ExactFit (image is stretched to fill screen
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(768, 1024, kResolutionShowAll);
    //if device's screen width is greater than 768, use high definition images
    if (screenSize.width > 768) {
        cocos2d::CCFileUtils::sharedFileUtils()->addSearchPath("hd");
//        CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
        pDirector->setContentScaleFactor(2);
        //or else, use standard definition
    } else {
        cocos2d::CCFileUtils::sharedFileUtils()->addSearchPath("sd");
//        CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
        pDirector->setContentScaleFactor(1);
    }
    
    //preload sound effects
    SimpleAudioEngine::sharedEngine()->preloadEffect( (CCFileUtils::sharedFileUtils()->fullPathForFilename("hit.wav")).c_str() );
    SimpleAudioEngine::sharedEngine()->preloadEffect( (CCFileUtils::sharedFileUtils()->fullPathForFilename("score.wav")).c_str() );
    // 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();
    CCScene *pScene = CCLobbyView::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 22
0
bool AppDelegate::applicationDidFinishLaunching()
{
	// initialize director
	CCDirector* pDirector = CCDirector::sharedDirector();
	CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
	pDirector->setOpenGLView(pEGLView);

	CCSize frameSize = pEGLView->getFrameSize();
	CCLOG("ScreenSize width:%f, height:%f", frameSize.width, frameSize.height);

#if (SCREEN_ORIENTATION == SCREEN_ORIENTATION_LANDSCAPE)		// 横屏
	float frameScale = frameSize.width/frameSize.height;
#elif (SCREEN_ORIENTATION == SCREEN_ORIENTATION_PORTRAIT)		// 竖屏
	float frameScale = frameSize.height/frameSize.width;
#else
	#error unknown target ORIENTATION!
#endif

	if( frameScale < 3.0f/2.0f )			// 窄屏,屏幕宽度:高度小于3:2
	{
		// Set the design resolution
		pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionShowAll);
	}
	else
	{
		// Set the design resolution
		pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
	}
	

	//use fixed resource
	float fScale = MIN(designResolutionRes.size.width/designResolutionSize.width, designResolutionRes.size.height/designResolutionSize.height);
//	CCFileUtils::sharedFileUtils()->setResourceDirectory(designResolutionRes.directory);
	pDirector->setContentScaleFactor(fScale);
	CCLOG("setContentScaleFactor fscale: %f, res.size(%f, %f), deSize(%f, %f)", fScale, designResolutionRes.size.width, designResolutionRes.size.height, designResolutionSize.width, designResolutionSize.height);

	// turn on display FPS   lyp 取消帧率
	//pDirector->setDisplayStats(true);

	// set FPS. the default value is 1.0/60 if you don't call this  lyp 取消帧率
	//pDirector->setAnimationInterval(1.0 / 50);

	// create a scene. it's an autorelease object
//	CCScene* pScene = CSceneInit::scene();
//	CCScene* pScene = SceneLogo::scene();
	CCLOG("GO TO LOGIN");
	CCScene* pScene = LoadingScene::scene(TargetSceneLoginScene);

	// run
	pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 23
0
bool AppDelegate::applicationDidFinishLaunching()
{
	// initialize director
	    CCDirector* pDirector = CCDirector::sharedDirector();
	    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

	    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
	    CCSize designSize = CCSizeMake(480,320);
	    std::vector<std::string> searchPaths;


	    if(screenSize.height>320) {
	    	searchPaths.push_back("HD");
	    	searchPaths.push_back("SD");
	    	pDirector->setContentScaleFactor(640.0f/designSize.height);
	    }
	    else {
	    	searchPaths.push_back("SD");
	    	pDirector->setContentScaleFactor(320.0f/designSize.height);
	    }

	    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

	    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, 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 = StartScene::create();

	    // run
	    pDirector->runWithScene(pScene);

	    return true;
}
Ejemplo n.º 24
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    //pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    CCSize screenSize = pDirector->getWinSize();
    CCLOG("%f %f", screenSize.width, screenSize.height);
    //CCSize screenSize = pEGLView->getFrameSize();
    //CCEGLView::sharedOpenGLView() -> setDesignResolutionSize(768, 1024, kResolutionExactFit);
    if (screenSize.width > 768) {
        CCLOG("hd");
        CCFileUtils::sharedFileUtils()->addSearchPath("hd");
        pDirector->setContentScaleFactor(2);
    } else {
        CCLOG("SD");
        //or else, use standard definition
        CCFileUtils::sharedFileUtils()->addSearchPath("sd");
        pDirector->setContentScaleFactor(1);
    }

    SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("hit.wav").c_str());
    SimpleAudioEngine::sharedEngine()->preloadEffect(CCFileUtils::sharedFileUtils()->fullPathForFilename("score.wav").c_str());
AVAudioSession
    // 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 = GameLayer::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 25
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    
    pDirector->setOpenGLView(pEGLView);
	
	// Set the design resolution
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionExactFit);
    CCSize frameSize = pEGLView->getFrameSize();
    std::vector<std::string> searchPath;
    
    // In this demo, we select resource according to the frame's height.
    // If the resource size is different from design resolution size, you need to set contentScaleFactor.
    // We use the ratio of resource's height to the height of design resolution,
    // this can make sure that the resource's height could fit for the height of design resolution.
    
    // if the frame's height is larger than the height of medium resource size, select large resource.
    float scaleFactor = 1.0f;
    if (frameSize.height > mediumResource.size.height) {
        searchPath.push_back(largeResource.directory);
        scaleFactor = 4.0f;
    }
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height) {
        searchPath.push_back(mediumResource.directory);
        scaleFactor = 2.0f;
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
    else {
        searchPath.push_back(smallResource.directory);
        scaleFactor = 1.0f;
    }
    pDirector->setContentScaleFactor(scaleFactor);
    
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
    
    // Init the view port with the frame size and scale factor
    this->initializeViewPort(frameSize, scaleFactor);
    
    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    
    // Initialize Nextpeer
    this->initializeNextpeer();
    
    // run
    pDirector->runWithScene(MainMenuLayer::scene());
    
    return true;
}
Ejemplo n.º 26
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    CCEGLView *pEGLView = CCEGLView::sharedOpenGLView();
    pDirector->setOpenGLView(pEGLView);
    
    //设置view size
    CCSize screenSize = pEGLView->getFrameSize();
    CCSize designSize = CCSize(320, 480);
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
    
    //设置资源路径
    std::vector<std::string> searchPaths;
    if (screenSize.width > 320 ) {  //临时把高清直接从小图放大
        searchPaths.push_back("iphone");    //iphonehd 临时
        pDirector->setContentScaleFactor(1);    //320/designSize.width 临时
    }else {
        searchPaths.push_back("iphone");
        pDirector->setContentScaleFactor(320/designSize.width);
    }
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

    // 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 = BattleField::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 27
0
bool AppDelegate::applicationDidFinishLaunching()
{
	// initialize director
	CCDirector *pDirector = CCDirector::sharedDirector();
	pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

	//    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, 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 / GAME_FPS);
	StringVector kSearchPaths;
	StringVector kOrders;

	if (!initSearchPaths(kSearchPaths))
	{
		CCLOG("Initialise searching path failed!");
		return false;
	}

	if (false == autoSizeMachineResolutions(kOrders))
	{
		return false;
	}

	CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(kOrders);

	pDirector->setContentScaleFactor(
		m_kResourceSize.width / m_kDesignSize.width);

	// register lua engine
	CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();

	CCLuaStack *pStack = pEngine->getLuaStack();
	lua_State *tolua_s = pStack->getLuaState();
	tolua_extensions_ccb_open(tolua_s);

	CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
	CCFileUtils::sharedFileUtils()->setSearchPaths(kSearchPaths);

	std::string strLuaPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(
		ENTRY_LUA_FUNC);
	CCLOG("Will exceute %s\n",strLuaPath.c_str());
	pEngine->executeScriptFile(strLuaPath.c_str());

	return true;
}
Ejemplo n.º 28
0
bool AppDelegate::applicationDidFinishLaunching()
{
	// As an example, load config file
	// XXX: This should be loaded before the Director is initialized,
	// XXX: but at this point, the director is already initialized
	CCConfiguration::sharedConfiguration()->loadConfigFile("configs/config-example.plist");

    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();

    CCSize designSize = CCSizeMake(480, 320);

    CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
    std::vector<std::string> searchPaths;
    
	if (screenSize.height > 320)
    {
        CCSize resourceSize = CCSizeMake(960, 640);
        searchPaths.push_back("hd");
		searchPaths.push_back("hd/scenetest");
        pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
    }
	else
	{
		searchPaths.push_back("scenetest");
	}
	pFileUtils->setSearchPaths(searchPaths);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
#else
	CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
#endif

    CCScene * pScene = CCScene::create();
    CCLayer * pLayer = new TestController();
    pLayer->autorelease();

    pScene->addChild(pLayer);
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 29
0
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;
}
Ejemplo n.º 30
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
    
    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
    
    CCSize designSize = CCSizeMake(480, 320);
    
    CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
    
    
    if (screenSize.height > 320)
    {
        CCSize resourceSize = CCSizeMake(960, 640);
        std::vector<std::string> searchPaths;
        searchPaths.push_back("hd");
        pFileUtils->setSearchPaths(searchPaths);
        pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
    }
    
    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);

    // create a scene. it's an autorelease object
//    CCScene *pScene = HelloWorld::scene();
    CocosGUIExamplesRegisterScene *pScene = new CocosGUIExamplesRegisterScene();
    pScene->autorelease();

    // run
    pDirector->runWithScene(pScene);

    return true;
}