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

    pDirector->setOpenGLView(pEGLView);
	CCSize frameSize = pEGLView->getFrameSize();
	
    // 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 FK windows console
	FKCW_Base_Utils::CreateWinConsole();

	// add resouce dir
	CCFileUtils::sharedFileUtils()->addSearchPath( "Resources" );

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

    // run
    pDirector->runWithScene(pScene);

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

	//pDirector->setProjection(kCCDirectorProjection2D);
    pDirector->setOpenGLView(pEGLView);
	CCSize frameSize = pEGLView->getFrameSize();

    //pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.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);

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

    // run
    pDirector->runWithScene(pScene);

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

    pDirector->setOpenGLView(pEGLView);
	CCSize frameSize = pEGLView->getFrameSize();
    
    // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
    TargetPlatform target = getTargetPlatform();
    if(target == kTargetIpad)
    {
        // ipad
        if(pDirector->enableRetinaDisplay(true))
        {
            // ipad hd
            CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
        }
        else
        {
            CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
        }
    }
    else if(target == kTargetIphone)
    {
        // iphone
        if(pDirector->enableRetinaDisplay(true))
        {
            if(pDirector->getWinSize().width > 480)
            {
                // iphone hd 4'
                CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
            }
            else
            {
                // iphone hd 3'
                CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
            }
        }
    }
	
    // turn on display FPS
    pDirector->setDisplayStats(true);

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

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

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Exemplo n.º 9
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;
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
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;
}
Exemplo n.º 12
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;
}
Exemplo n.º 13
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;
}
Exemplo n.º 14
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;
}
Exemplo n.º 15
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;
}
Exemplo n.º 16
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;
}
Exemplo n.º 17
0
bool AppDelegate::applicationDidFinishLaunching()
{
	CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    CCDirector *pDirector = CCDirector::sharedDirector();
	pDirector->setOpenGLView(eglView);

    // turn on display FPS
    pDirector->setDisplayStats(ShowFrame);
    pDirector->setAnimationInterval(1.0 / 60);

	CCSize frameSize = eglView->getFrameSize();
	eglView->setDesignResolutionSize(frameSize.width, frameSize.height, kResolutionNoBorder);

    // create a scene. it's an autorelease object
	//Ö÷²Ëµ¥
	CCScene* pScene = MainScene::create();
	//CCScene* pScene = GameScene::create();
	//CCScene* pScene = CMainMenu::StartMenu();
	pDirector->runWithScene(pScene);
    return true;
}
Exemplo n.º 18
0
int piantou::shiying(int sr)
{
//       CCDirector *pDirector = CCDirector::sharedDirector();
    CCSize ww=CCDirector::sharedDirector()->getWinSize();
       CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    CCSize frameSize = pEGLView->getFrameSize();
    if (frameSize.height>768) {
        return sr;
        
        
    }
    else if (frameSize.height>320) {
        return sr/2;
    }
    else
    {
        return sr/4;
    }
    

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

    pDirector->setOpenGLView(pEGLView);
	CCSize frameSize = pEGLView->getFrameSize();

    // Set the design resolution
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionShowAll);
#else
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
#endif

    
      //ÉèÖÃcontentScaleFactor
    pDirector->setContentScaleFactor(1);//µ±×ÊÔ´³ß´çÓëdesign³ß´ç²»Í¬Ê±ÐèҪʹÓÃËüÀ´½øÐÐËõ·Å

   
    // set searching path
	vector<string> searchPath;
    searchPath.push_back(resourceSearchDic);
    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);

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

    // run
    pDirector->runWithScene(pScene);

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

    pDirector->setOpenGLView(pEGLView);
	CCSize frameSize = pEGLView->getFrameSize();
	gDesignSize.width = 480;
	gDesignSize.height = 320;

	float fResouceWH = gDesignSize.width / gDesignSize.height;
	float fViewWH = frameSize.width / frameSize.height;
	if (fViewWH >= fResouceWH)
	{
		pEGLView->setDesignResolutionSize(gDesignSize.width, gDesignSize.height, kResolutionFixedHeight);
		gSolutionType = kResolutionFixedHeight;
	} 
	else
	{
		pEGLView->setDesignResolutionSize(gDesignSize.width, gDesignSize.height, kResolutionFixedWidth);
		gSolutionType = kResolutionFixedWidth;
	}
	gViewSize = pEGLView->getVisibleSize();
    // 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 = GameLayer::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Exemplo n.º 22
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, kResolutionShowAll);//kResolutionExactFit,kResolutionNoBorder,kResolutionShowAll,kResolutionUnKnown
    float rate1 =2.0;
    float rate2 =2.0;
    
    //pEGLView->setDesignResolutionSize(2048/rate1, 1536/rate2, kResolutionShowAll);
    
   
	CCSize frameSize = pEGLView->getFrameSize();
    
    vector<string> searchPath;
    
	if (frameSize.height > mediumResource.size.height)
	{
        searchPath.push_back(largeResource.directory);
     
        //pDirector->setContentScaleFactor(MIN(largeResource.size.height/(2048/rate1), largeResource.size.width/(1536/rate2)));
	}
    // 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/(2048/rate1), mediumResource.size.width/(1536/rate2)));
    }
    // 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/(2048/rate1), smallResource.size.width/(1536/rate2)));
    }
 
    // set searching path
    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);
    
    // create a scene. it's an autorelease object
    CCScene *pScene = CompanyInfo::scene();
    
    // run
    pDirector->runWithScene(pScene);
    
    glClearColor(1.0, 1.0, 1.0, 1.0);//changeBackGroundDefautColor
    
    return true;
}
Exemplo n.º 23
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
//    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

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

    //--------------------------------------------------------------------------
    std::vector<std::string> searchPath = CCFileUtils::sharedFileUtils()->getSearchPaths();;
    // initialize director
//    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    pDirector->setOpenGLView(pEGLView);
    // Set the design resolution
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, 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 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(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)
    {
            searchPath.push_back(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
    {
            searchPath.push_back(smallResource.directory);
            pDirector->setContentScaleFactor(smallResource.size.height/designResolutionSize.height);
     }
    
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
    //--------------------------------------------------------------------------
    
    // create a scene. it's an autorelease object
//    CCScene *pScene = HelloWorld::scene();
    //CCScene *pScene = Joystick::scene();
//    CCScene *pScene = GameMenu::scene();
//    CCScene *pScene = MapLoading::scene();
    CCScene *pScene = PlayingScene::scene();
    // run
    pDirector->runWithScene(pScene);

    //-----------***************************************************************
    // initialize director
//    CCDirector *pDirector = CCDirector::sharedDirector();
//    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
//
//    CCSize designSize = CCSizeMake(480, 320);
//    CCSize resourceSize = CCSizeMake(480, 320);
//    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
//
//    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-iOS");
//        searchPaths.insert(searchPaths.begin(), "Resources");
//        CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
//
//        if (screenSize.height > 768)
//        {
//            resourceSize = CCSizeMake(2048, 1536);
//            resDirOrders.push_back("resources-ipadhd");
//        }
//        else if (screenSize.height > 640)
//        {
//            resourceSize = CCSizeMake(1536, 768);
//            resDirOrders.push_back("resources-ipad");
//        }else if (screenSize.height > 320)
//        {
//            resourceSize = CCSizeMake(960, 640);
////            resDirOrders.push_back("resources-iphonehd");
////            searchPaths.push_back("resources-iphonehd");
//            resDirOrders.push_back("iPhone_hd");
//
//        }
//        else
//        {
////            resDirOrders.push_back("resources-iphone");
////            searchPaths.push_back("resources-iphone");
//            resDirOrders.push_back("iPhone");
//        }
//        CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
//    }
//    else if (platform == kTargetAndroid || platform == kTargetWindows)
//    {
//
//        if (screenSize.width > 720)
//        {
//            resourceSize = CCSizeMake(960, 640);
//            resDirOrders.push_back("iPhone_hd");
//        }
//        else if (screenSize.width > 568)
//        {
//            resourceSize = CCSizeMake(720, 480);
//            resDirOrders.push_back("iPhone_hd");
//        }
//        else
//        {
//            resourceSize = CCSizeMake(568, 320);
//            resDirOrders.push_back("iPhone_hd");
//        }
//    }
//
//    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->start();
////
////    CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
////    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
////    ScriptingCore::getInstance()->runScript("main.js");
//    
//    CCScene *pScene = PlayingScene::scene();
//    //    // run
//    pDirector->runWithScene(pScene);
    
    return true;
}
Exemplo n.º 24
0
bool AppDelegate::applicationDidFinishLaunching() {

    CCLog("Finished launching");
    srand(time(0));
    System::_ld.init();

    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

    // Set the design resolution
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, 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.
    CCSize vsize = pEGLView->getVisibleSize();
    // if the frame's height is larger than the height of medium resource size, select large resource.
    float width_change = vsize.width / designResolutionSize.width;
    // if the frame's height is larger than the height of medium resource size, select large resource.
    CCFileUtils::sharedFileUtils()->setResourceDirectory(mediumResource.directory);
    pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height/width_change, mediumResource.size.width/designResolutionSize.width/width_change));


    // 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
    ScriptPtr main_script(0);
    IntentParams::Mode mode = IntentParams::getInstance().getMode();

    if(mode == IntentParams::WakeUpMode)
        main_script = ScriptPtr(new WakeUpScript);
    else
        main_script = ScriptPtr(new MainScript);

    loadTranslation(getDeviceLang());
    configureContentProviders();
    //
    //JokesHolder::sharedHolder().updateJokes();




    CCScene *pScene = ScriptScene::scene(main_script);
    // run
    pDirector->runWithScene(pScene);

    _is_running = true;


    CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("choose.wav");
    return true;
}
Exemplo n.º 25
0
bool threePScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
    CCSize frameSize = pEGLView->getFrameSize();
    int fw = frameSize.width , fh = frameSize.height ;
    
    //效果3,需要包含4种Scene,4种切换效果
    char imgname1[50] , imgname2[50] , imgname3[50] ;
    snprintf(imgname1, sizeof(imgname1), "/Users/liuyou/Desktop/new/%d.jpg", threeimgid ) ;
    threeimgid ++ ;
    snprintf(imgname2, sizeof(imgname2), "/Users/liuyou/Desktop/new/%d.jpg" , threeimgid ) ;
    threeimgid ++ ;
    snprintf(imgname3, sizeof(imgname3), "/Users/liuyou/Desktop/new/%d.jpg",threeimgid);
    
    int aniType = rand()%2 ;
    
    CCSprite *sp1 , *sp2 , *sp3 ;
    CCActionInterval *act1 , *act2 , *act3 , *act4 , *act5 , *act ;
    sp1 = CCSprite::create(imgname1);
    sp2 = CCSprite::create(imgname2);
    sp3 = CCSprite::create(imgname3);
    
    if ( aniType <= 1 )
    {
        //sp1为背景在移动
        int sw1 = sp1->getContentSize().width , sh1 = sp1->getContentSize().height ;
        double scaleRate1 = ImageAdapter::adapterFullBackGround(sp1->getContentSize(), frameSize);
        sp1->setScale( scaleRate1 );
        sw1 *= scaleRate1 ; sh1 *= scaleRate1 ;
        
        if ( sw1 - fw >= 10 )
        {
            //往左走
            int sx = fw - sw1/2 ;
            int sy = fh / 2 ;
            int tx = sw1/2 ;
            if ( sw1 - fw > 20 )
            {
                tx -= 10 ;
            }
            int ty = sy ;
            sp1->setPosition( ccp( sx, sy ) ) ;
            
            act1 = CCMoveTo::create(3, ccp(tx,ty));
        }else if ( sh1 - fh >= 10 )
        {
                //往上走
            int sx = fw / 2 ;
            int sy = fh - sh1 / 2 ;
            int tx = sx ;
            int ty = sh1 / 2 ;
            if ( sh1 - fh > 20 )
            {
                ty -= 10 ;
            }
            sp1->setPosition(ccp(sx,sy)) ;
            act1 = CCMoveTo::create(3,ccp(tx,ty));
            
        }else
        {
            sp1->setPosition(ccp(fw/2,fh/2));
            act1 = CCScaleTo::create(3, 1.1);
        }
        
        //sp2从最左边fw/3 从下往上
        int sw2 = sp2->getContentSize().width , sh2 = sp2->getContentSize().height ;
        double scrx2 = ((double)fw/3.0)/sp2->getContentSize().width;
        double scry2 ;
        if ( sp2->getContentSize().height * scrx2 >= fh + 20.0 ) scry2 = scrx2 ;
        else scry2 = ( (double)fh + 20.0 ) / sp2->getContentSize().height ;
        sp2->setScaleX(scrx2) ; sp2->setScaleY(scry2);
        sw2 *= scrx2 ; sh2 *= scry2 ;
        
        int sx2 = sw2 / 2 , sy2 = -sh2 / 2 ;
        int tx2 = sw2 / 2 , ty2 = fh - sh2/2 ;
        sp2->setPosition(ccp(sx2,sy2));
        act2 = CCMoveTo::create(0.5, ccp(tx2,ty2));
        ty2 = sh2 / 2 ;
        act3 = CCMoveTo::create(2.5,ccp(tx2,ty2));
        
        
        //sp3从中间fw3 从上往下
        int sw3 = sp3->getContentSize().width , sh3 = sp3->getContentSize().height ;
        double scrx3 = (fw/3.0) / sp3->getContentSize().width ;
        double scry3 ;
        if ( sp3->getContentSize().height * scrx3 >= fh + 20 ) scry3 = scrx3 ;
        else scry3 = ( fh + 20 ) / sp3->getContentSize().height ;
        sp3->setScaleX(scrx3) ; sp3->setScaleY(scry3);
        sw3 *= scrx3 ; sh3 *= scry3;
        
        int sx3 = fw/3 + sw3 / 2 , sy3 = fh + sh3 / 2 ;
        int tx3 = fw/3 + sw3 / 2 , ty3 = sh3 / 2;
        sp3->setPosition(ccp(sx3,sy3));
        act4 = CCMoveTo::create(0.5,ccp(tx3,ty3));
        ty3 =  fh - sh3/2;
        act5 = CCMoveTo::create(2.5, ccp(tx3, ty3));
    }else
    {
        
    }
    
    this->addChild(sp1,0);
    this->addChild(sp2,1);
    this->addChild(sp3,2);
    
    CCCallFuncN *cfn = CCCallFuncN::create(this, callfuncN_selector(threePScene::changeScene));
    sp1->runAction(act1);
    sp2->runAction(CCSequence::create(act2,act3,NULL));
    sp3->runAction(CCSequence::create(act4,act5,cfn,NULL));
    return true;
}
Exemplo n.º 26
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, 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.

	CCLOG("framesize.height %f framesize.width %f",frameSize.height,frameSize.width);

    // 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(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)
    { 
        CCFileUtils::sharedFileUtils()->setResourceDirectory(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
    { 
		CCFileUtils::sharedFileUtils()->setResourceDirectory(smallResource.directory);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }

    //add two special cases
    if(frameSize.height == 600.0 && frameSize.width == 1024.0)
    {
         CCFileUtils::sharedFileUtils()->setResourceDirectory(galaxypadResource.directory);
        pDirector->setContentScaleFactor(MIN(galaxypadResource.size.height/designResolutionSize.height, galaxypadResource.size.width/designResolutionSize.width));
    }
    if(frameSize.height == 640.0 && frameSize.width == 960.0)
    {
         CCFileUtils::sharedFileUtils()->setResourceDirectory(retinaResource.directory);
        pDirector->setContentScaleFactor(MIN(retinaResource.size.height/designResolutionSize.height, retinaResource.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 = LoadingScene::create();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Exemplo n.º 27
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    CCEGLView* pEglView = CCEGLView::sharedOpenGLView();
    
    pDirector->setOpenGLView(pEglView);
    
    // Set resolution size and paths
    pEglView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
    CCSize frameSize = pEglView->getFrameSize();
    
    vector<string> searchPaths;
    
    if(frameSize.width < designResolutionSize.width)
    {
        
    }
    
    
    /*
    if(frameSize.height > smallResource.size.height)
    {
        searchPaths.push_back(mediumResource.directory);
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
    }
    else
    {
        searchPaths.push_back(smallResource.directory);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    */
    
    searchPaths.push_back(mediumResource.directory);
    pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
    
    searchPaths.push_back("audio");
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
    
    SimpleAudioEngine::sharedEngine()->preloadEffect(SFX_JUMP);
    SimpleAudioEngine::sharedEngine()->preloadEffect(SFX_SWOOSH);
    SimpleAudioEngine::sharedEngine()->preloadEffect(SFX_SMASH);
    SimpleAudioEngine::sharedEngine()->preloadEffect(SFX_BUTTON);
    SimpleAudioEngine::sharedEngine()->preloadEffect(SFX_LIGHTNING);
    
    SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(BG_MUSIC_01);
    SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(BG_MUSIC_02);
    SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(BG_MUSIC_03);
    
    SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(BG_MUSIC_VOLUME);
    SimpleAudioEngine::sharedEngine()->setEffectsVolume(1.0f);
    

    // turn on display FPS
    pDirector->setDisplayStats(SHOW_FPS);

    // 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 = HomeScene::scene(kGameModeHome);
    // run
    pDirector->runWithScene(pScene);

    return true;
}
Exemplo n.º 28
0
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;
}
Exemplo n.º 29
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, 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

	//directly jump to the human play menu
	/*AcquireGameScene::loadTexture();
	AcquireSelectScene *pScene = AcquireSelectScene::create();
	AcquireGameScene* pGameScene = AcquireGameScene::create();
	pGameScene->initGameWithSelection( pScene );
	pDirector->runWithScene(pGameScene);*/

	//directly jump to the end play menu
	/*AcquireGameScene::loadTexture();
	AcquireSelectScene *pScene = AcquireSelectScene::create();
	AcquireGameScene* pGameScene = AcquireGameScene::create();
	pGameScene->initGameWithSelection( pScene );
    CCScene *s = AcquireGameScene::create_gameend_scene();
	s->addChild( pGameScene->create_static_layer() );
	pDirector->runWithScene(s);*/
    
	//AcquireGameScene *pScene = AcquireGameScene::create();
	//AcquireGameScene::loadTexture();
	//AcquireSelectScene *pScene = AcquireSelectScene::create();
	//CCScene *pScene = AcquireGameScene::create_splash_scene();
	//CCScene *pScene = AcquireGameScene::create_gameend_scene();
	//pDirector->runWithScene(pScene);
	//pScene ->switchToGameScene(NULL);
	//pDirector->runWithScene( pScene->create_gameend_scene() );
	
	//standard procedure
	CCScene *pScene = AcquireGameScene::create_splash_scene();
	pDirector->runWithScene(pScene);
    return true;
}
Exemplo n.º 30
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
	CCSize frameSize = pEGLView->getFrameSize();

    pDirector->setOpenGLView(pEGLView);

    std::vector<std::string> searchPaths;

#if MC_ADAPTIVE_RESOLUTION == 1
    // Set the design resolution
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    pEGLView->setDesignResolutionSize(PCResource.size.width, PCResource.size.height, kResolutionExactFit);
    searchPaths.push_back(PCResource.directory);
//    pDirector->setContentScaleFactor(MIN(32 * 25 / PCResource.size.width, 32 * 15 / PCResource.size.height));
//    pDirector->setContentScaleFactor(0.75f);
    pDirector->setContentScaleFactor(MIN(32 * 25 / frameSize.width, 32 * 15 / frameSize.height));
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height == smallResource.size.height) {
        pEGLView->setDesignResolutionSize(smallResource.size.width, smallResource.size.height, kResolutionNoBorder);
        searchPaths.push_back(smallResource.directory);
	}
        // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height == mediumResource.size.height) {
        pEGLView->setDesignResolutionSize(mediumResource.size.width, mediumResource.size.height, kResolutionNoBorder);
        searchPaths.push_back(mediumResource.directory);
    }
        // if the frame's height is smaller than the height of medium resource size, select small resource.
	else {
        pEGLView->setDesignResolutionSize(largeResource.size.width, largeResource.size.height, kResolutionNoBorder);
		searchPaths.push_back(largeResource.directory);
    }
    pDirector->setContentScaleFactor(MIN(32 * 25 / frameSize.width, 32 * 15 / frameSize.height));
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    int i = 0;
    int size = sizeof(resources);
    int found = 0;
    for (; i < size; ++i) {
        if ((frameSize.width == resources[i].size.width && frameSize.height == resources[i].size.height)
            || (frameSize.width == resources[i].size.height && frameSize.height == resources[i].size.width)) {
            searchPaths.push_back(resources[i].directory);
            pEGLView->setDesignResolutionSize(resources[i].size.width, resources[i].size.height, kResolutionNoBorder);
            pDirector->setContentScaleFactor(MIN(32 * 25 / resources[i].size.width, 32 * 15 / resources[i].size.height));
            found = 1;
            break;
        }
    }
    if (found == 0) {
		searchPaths.push_back(resources[0].directory);
        pEGLView->setDesignResolutionSize(resources[0].size.width, resources[0].size.height, kResolutionNoBorder);
        pDirector->setContentScaleFactor(MIN(32 * 25 / resources[0].size.width, 32 * 15 / resources[0].size.height));
    }
#else
    // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height > mediumResource.size.height) {
        searchPaths.push_back(largeResource.directory);
        pEGLView->setDesignResolutionSize(largeResource.size.width, largeResource.size.height);
        pDirector->setContentScaleFactor(MIN(largeResource.size.height/smallResource.size.height, largeResource.size.width/smallResource.size.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) {
        searchPaths.push_back(mediumResource.directory);
        pEGLView->setDesignResolutionSize(mediumResource.size.width, mediumResource.size.height);
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height/smallResource.size.height, mediumResource.size.width/smallResource.size.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
	else {
		searchPaths.push_back(smallResource.directory);
        pEGLView->setDesignResolutionSize(smallResource.size.width, smallResource.size.height);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height, smallResource.size.width));
    }
#endif // platforms
#else
    CCSize designSize = CCSizeMake(960, 640);
    
    searchPaths.push_back(CommonResource.directory);
    if (frameSize.height > 1280) {
        CCSize resourceSize = CCSizeMake(2048, 1536);
        std::vector<std::string> searchPaths;
//        searchPaths.push_back("hd"); //没资源
        pDirector->setContentScaleFactor(0.75 * resourceSize.height / designSize.height);
    } else {
        pDirector->setContentScaleFactor(0.75);
    }
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionFixedWidth);
#endif // MC_ADAPTIVE_RESOLUTION == 0
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
	
    // 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);
    
    CCLog("%s(%d): %.0f %.0f %.0f", __FILE__, __LINE__, frameSize.width, frameSize.height, pDirector->getContentScaleFactor());
    
    // register lua engine
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
    
#if MC_DEBUG_SERVER == 1
    MCSimpleGameSceneContextServer *server = MCSimpleGameSceneContextServer::defaultSimpleGameSceneContextServer();
    server->setPort(kMCListeningPort);
    server->runloop();
#endif
    
    // run
//    pDirector->pushScene(MCMainMenuLayer::scene());
//    pDirector->runWithScene(MCSplashLayer::scene());
    
    pDirector->runWithScene(MCTestbed::scene());

    return true;
}