Ejemplo n.º 1
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *director = Director::getInstance();
    director->setOpenGLView(EGLView::getInstance());
    
    // turn on display FPS
    director->setDisplayStats(true);
    
    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);
    
    ScriptingCore* sc = ScriptingCore::getInstance();
    sc->addRegisterCallback(register_all_cocos2dx);
    sc->addRegisterCallback(register_all_cocos2dx_extension);
    sc->addRegisterCallback(register_cocos2dx_js_extensions);
    sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
    sc->addRegisterCallback(jsb_register_chipmunk);
    sc->addRegisterCallback(JSB_register_opengl);
    sc->addRegisterCallback(jsb_register_system);
    sc->start();
    
    ScriptEngineProtocol *engine = ScriptingCore::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(engine);
    ScriptingCore::getInstance()->runScript("cocos2d-jsb.js");
       
    return true;
}
Ejemplo n.º 2
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* director = Director::getInstance();
    EGLView* eglView = EGLView::getInstance();

    // チラツキ対策
//    Director::getInstance()->setProjection(Director::Projection::_2D);
    Director::getInstance()->setDepthTest(false);
  
    Director::getInstance()->setOpenGLView(eglView);
	
    // 800x480基準
    eglView->setDesignResolutionSize(800.0 * 0.6,
                                     480.0 * 0.6,
                                     ResolutionPolicy::SHOW_ALL);
    
    // turn on display FPS
    director->setDisplayStats(true);

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

    // create a scene. it's an autorelease object
//    Scene *pScene = GameScene::scene();
    auto *pScene = TitleSceneLoader::createScene();

    // run
    director->runWithScene(pScene);

    return true;
}
Ejemplo n.º 3
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
	Director* director = Director::getInstance();
	GLView* glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("My Game");
        director->setOpenGLView(glview);
    }

    // turn on display FPS
    director->setDisplayStats(true);

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

    register_all_packages();

    // create a scene. it's an autorelease object
    Scene* scene = WelcomeScene::scene();

    // run
    director->runWithScene(scene);

    SimpleAudioEngine::getInstance()->preloadBackgroundMusic("sounds/BgmCity.mp3");
    SimpleAudioEngine::getInstance()->playBackgroundMusic("sounds/BgmCity.mp3",true);
    return true;
}
Ejemplo n.º 4
0
bool AppDelegate::applicationDidFinishLaunching() {
	// initialize director
	Director* director = Director::getInstance();
	EGLView* eglView = EGLView::getInstance();

	director->setOpenGLView(eglView);

	// turn on display FPS
	director->setDisplayStats(true);

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

	Size screenSize = Director::getInstance()->getWinSize();
	screenHeight = screenSize.height;
	screenWidth = screenSize.width;
	factorX = screenWidth / designWidth;
	factorY = screenHeight / designHeight;
	scaledWidth = screenWidth*factorX;
	scaledHeight = screenHeight*factorY;

	// create a scene. it's an autorelease object
	Scene *scene = MainMenuLayer::scene();
	// run
	director->runWithScene(scene);
	return true;
}
Ejemplo n.º 5
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* pDirector = Director::sharedDirector();
    EGLView* pEGLView = EGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

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

	Size 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
    FileUtils::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
    Scene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 6
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *director = Director::getInstance();
    director->setOpenGLView(EGLView::getInstance());
    
    // turn on display FPS
    director->setDisplayStats(true);
    
    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);
    
    ScriptingCore* sc = ScriptingCore::getInstance();
    sc->addRegisterCallback(register_all_cocos2dx);
    sc->addRegisterCallback(register_all_cocos2dx_extension);
    sc->addRegisterCallback(register_cocos2dx_js_extensions);
    sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
    sc->addRegisterCallback(jsb_register_chipmunk);
    sc->addRegisterCallback(JSB_register_opengl);
    sc->addRegisterCallback(jsb_register_system);
    sc->addRegisterCallback(register_mask_all);
    sc->start();
    
    ScriptEngineProtocol *engine = ScriptingCore::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(engine);
    ScriptingCore::getInstance()->runScript("cocos2d-jsb.js");

    cocos2d::plugin::TAdsDeveloperInfo devInfo;
    devInfo["AdmobID"] = "a1530e0a2793b0f"; /*my id*/
    cocos2d::plugin::ProtocolAds* admob =  dynamic_cast<cocos2d::plugin::ProtocolAds*>(cocos2d::plugin::PluginManager::getInstance()->loadPlugin("AdsAdmob"));
    cocos2d::plugin::AdsListener* listener = new MyAdsListener();
    cocos2d::plugin::ProtocolAds::AdsPos posAdmob = cocos2d::plugin::ProtocolAds::kPosTopLeft;
    cocos2d::plugin::TAdsInfo adInfo;
    admob->configDeveloperInfo(devInfo);
    admob->setAdsListener(listener);
    admob->setDebugMode(false);
    adInfo["AdmobType"] = "1";
    adInfo["AdmobSizeEnum"] = "1";
    admob->showAds(adInfo, posAdmob);

    return true;
}
Ejemplo n.º 7
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director & GLView
    Director *director = Director::getInstance();
    director->setProjection(Director::Projection::_2D);

    // turn on display FPS
    director->setDisplayStats(true);

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

    // create a scene. it's an autorelease object
//    Scene *scene = CCColorMatrixFunctionalTestScene::scene();
    Scene *scene = MainMenuScene::scene();

    // run
    director->runWithScene(scene);

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

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

    // run
    pDirector->runWithScene(pScene);

    return true;
}
Ejemplo n.º 9
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* director = Director::getInstance();
    EGLView* eglView = EGLView::getInstance();

    director->setOpenGLView(eglView);
	
    // turn on display FPS
    director->setDisplayStats(true);

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

    // create a scene. it's an autorelease object
    Scene *scene = MainScene::getMainScene();

    // run
    director->runWithScene(scene);

    return true;
}
Ejemplo n.º 10
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director *director = Director::getInstance();

    director->setOpenGLView(EGLView::getInstance());

    Size screenSize = EGLView::getInstance()->getFrameSize();
    Size designSize = Size(480, 320);
    std::vector<std::string> searchPaths;

    if (screenSize.height > 320)
    {
        searchPaths.push_back("hd");
        searchPaths.push_back("sd");
        director->setContentScaleFactor(640.0f/designSize.height);
    }
    else
    {
        searchPaths.push_back("sd");
        director->setContentScaleFactor(320.0f/designSize.height);
    }

    FileUtils::getInstance()->setSearchPaths(searchPaths);

    EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER);

    // turn on display FPS
    director->setDisplayStats(true);

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

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

    // run
    director->runWithScene(scene);

    return true;
}
Ejemplo n.º 11
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *director = Director::getInstance();
    director->setOpenGLView(EGLView::getInstance());


    // turn on display FPS
    director->setDisplayStats(false);

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

    // register lua engine
    LuaEngine* engine = LuaEngine::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(engine);
    
    std::string path = FileUtils::getInstance()->fullPathForFilename("Script/main.lua");
    engine->executeScriptFile(path.c_str());

    return true;
}
Ejemplo n.º 12
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *pDirector = Director::sharedDirector();
    pDirector->setOpenGLView(EGLView::sharedOpenGLView());
    
    EGLView::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 / 60);

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

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

    return true;
}
Ejemplo n.º 13
0
bool TRenderApplication::applicationDidFinishLaunching(){
    Director* director = Director::getInstance();
    EGLView* glView = EGLView::getInstance();
    director->setOpenGLView(glView);
    Size FrameSize = glView->getFrameSize();
    glView->setDesignResolutionSize(900,600,ResolutionPolicy::NO_BORDER);
    director->setDisplayStats(false);
    director->setAnimationInterval(1.0/60);
    SetFilePath(std::string("..\\resource\\"));
    
    Scene* scene = Scene::create();
    TBaseObject * worklayer = new TBaseObject;
    if(worklayer && worklayer->initWithColor(Color4B(0,100,100,255))){
		SetWorkScene((int)worklayer);
	worklayer->setScale(0.35f);
	worklayer->autorelease();
	scene->addChild(worklayer);
    }
    scene->setPositionX(-200);
    scene->setPositionY(100);
    director->runWithScene(scene);
    return true;
}
Ejemplo n.º 14
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *pDirector = Director::sharedDirector();
    pDirector->setOpenGLView(EGLView::sharedOpenGLView());

    // JS-Test in Html5 uses 800x450 as design resolution
    EGLView::sharedOpenGLView()->setDesignResolutionSize(800, 450, kResolutionFixedHeight);
    // turn on display FPS
    pDirector->setDisplayStats(true);

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

    ScriptingCore* sc = ScriptingCore::getInstance();
    sc->addRegisterCallback(register_all_cocos2dx);
    sc->addRegisterCallback(register_all_cocos2dx_extension);
    sc->addRegisterCallback(register_cocos2dx_js_extensions);
    sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
    sc->addRegisterCallback(jsb_register_chipmunk);
    sc->addRegisterCallback(JSB_register_opengl);
    sc->addRegisterCallback(jsb_register_system);
    sc->addRegisterCallback(MinXmlHttpRequest::_js_register);
    sc->addRegisterCallback(register_jsb_websocket);

    sc->start();

    ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
    ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
#ifdef JS_OBFUSCATED
    ScriptingCore::getInstance()->runScript("game.js");
#else
    ScriptingCore::getInstance()->runScript("tests-boot-jsb.js");
#endif
    return true;
}
Ejemplo n.º 15
0
bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    Director *pDirector = Director::getInstance();
    pDirector->setOpenGLView(EGLView::getInstance());
    pDirector->setProjection(Director::Projection::_2D);


    Size screenSize = EGLView::getInstance()->getFrameSize();

    Size designSize = Size(320, 480);
    Size resourceSize = Size(320, 480);
    
    std::vector<std::string> searchPaths;
    std::vector<std::string> resDirOrders;
    
    Application::Platform platform = Application::getInstance()->getTargetPlatform();
    if (platform == Application::Platform::OS_IPHONE || platform == Application::Platform::OS_IPAD || platform == Application::Platform::OS_MAC)
    {
        searchPaths.push_back("Published-iOS"); // Resources/Published-iOS
        FileUtils::getInstance()->setSearchPaths(searchPaths);

        if (screenSize.height > 480)
        {
            resourceSize = Size(640, 960);
            resDirOrders.push_back("resources-iphonehd");
        }
        else
        {
            resDirOrders.push_back("resources-iphone");
        }
        
        FileUtils::getInstance()->setSearchResolutionsOrder(resDirOrders);
    }
    else if (platform == Application::Platform::OS_ANDROID || platform == Application::Platform::OS_WINDOWS)
    {
        // Comments it since opengles2.0 only supports texture size within 2048x2048.
//        if (screenSize.height > 1024)
//        {
//            resourceSize = Size(1280, 1920);
//            resDirOrders.push_back("resources-xlarge");
//            resDirOrders.push_back("");
//        }
//        else 
        if (screenSize.height > 960)
        {
            resourceSize = Size(640, 960);
            resDirOrders.push_back("resources-large");
            resDirOrders.push_back("resources-medium");
            resDirOrders.push_back("resources-small");
        }
        else if (screenSize.height > 480)
        {
            resourceSize = Size(480, 720);
            resDirOrders.push_back("resources-medium");
            resDirOrders.push_back("resources-small");
        }
        else
        {
            resourceSize = Size(320, 568);
            resDirOrders.push_back("resources-small");
        }
        
        FileUtils::getInstance()->setSearchResolutionsOrder(resDirOrders);
    }
    pDirector->setContentScaleFactor(resourceSize.width/designSize.width);

    EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL);
    
    // turn on display FPS
    pDirector->setDisplayStats(true);
    
    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    
    ScriptingCore* sc = ScriptingCore::getInstance();
    sc->addRegisterCallback(register_all_cocos2dx);
    sc->addRegisterCallback(register_all_cocos2dx_extension);
    sc->addRegisterCallback(register_cocos2dx_js_extensions);
    sc->addRegisterCallback(jsb_register_chipmunk);
    sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
    sc->addRegisterCallback(register_CCBuilderReader);
    sc->addRegisterCallback(jsb_register_system);
    sc->addRegisterCallback(JSB_register_opengl);
    
    sc->start();

    js_log("RUNNING Main");
    ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
    ScriptingCore::getInstance()->runScript("main.js");
       
    return true;
}
Ejemplo n.º 16
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* pDirector = gDirector;
    
    GLView* pGLView = pDirector->getOpenGLView();
    if( NULL == pGLView )
    {
        pGLView = GLView::create("game(v1.0.0.0)---test for inner");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
        pGLView->setFrameSize(1334, 750);
#endif
        
        pDirector->setOpenGLView(pGLView);
    }
    
    // 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);
    
    // resolution information  
    Size size;  
    size= pDirector->getWinSize();
	log("***IDONG: Director getWinSize:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getWinSizeInPixels();  
	log("***IDONG: Director getWinSizeInPixels:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getVisibleSize();  
	log("***IDONG: Director getVisibleSize:w=%f,h=%f",size.width,size.height);  

	Point point = pDirector->getVisibleOrigin();  
	log("***IDONG: Director getVisibleOrigin:x=%f,y=%f",point.x,point.y);  


	log("***IDONG: Director BS: getContentScaleFactor: scaleFactor=%f",pDirector->getContentScaleFactor());  

	auto framsize = pGLView->getFrameSize();
	auto dwinsize = pDirector->getWinSize();
	auto designsize = Size(SCREEN_WIDTH, SCREEN_HEIGHT);
	auto widthRate = framsize.width/designsize.width;
	auto heightRate = framsize.height/designsize.height;

	auto  resolutionRate = 1.f;
	if(widthRate > heightRate) 
	{
		pGLView->setDesignResolutionSize(designsize.width,
		 designsize.height*heightRate/widthRate, ResolutionPolicy::NO_BORDER);
		 resolutionRate = heightRate/widthRate;
	}
	else
	{
		pGLView->setDesignResolutionSize(designsize.width*widthRate/heightRate, designsize.height,
		 ResolutionPolicy::NO_BORDER);
		 resolutionRate = widthRate/heightRate;
	}

	//pGLView->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, ResolutionPolicy::FIXED_HEIGHT);

	log("***IDONG:/n");  
	log("***IDONG: Director AS: getContentScaleFactor: scaleFactor=%f",pDirector->getContentScaleFactor());  

	size= pDirector->getWinSize();  
	log("***IDONG: Director getWinSize:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getWinSizeInPixels();  
	log("***IDONG: Director getWinSizeInPixels:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getVisibleSize();  
	log("***IDONG: Director getVisibleSize:w=%f,h=%f",size.width,size.height);  

	point = pDirector->getVisibleOrigin();  
	log("***IDONG: Director getVisibleOrigin:x=%f,y=%f",point.x,point.y);  

	// ‘ˆº”À—À˜¬∑æ∂
	gFileUtils->addSearchPath("assets");

	// …Ë÷√◊ ‘¥ƒø¬�?
	// ≥ı ºªØ◊ ‘¥ƒø¬�?dumpŒƒº˛…˙≥…ƒø¬�?
	string logfile = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	gGameManager->SetResourceRoot("/mnt/sdcard/com.zm.mszb/");
	gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
	gGameManager->CreateDirectory(gGameManager->GetLogPath());
	logfile = gGameManager->GetLogPath()+"/log.txt";
	gLog->Open(logfile.c_str());
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	gGameManager->SetResourceRoot("");
	gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
	gGameManager->CreateDirectory(gGameManager->GetLogPath());
	logfile = gGameManager->GetLogPath()+"/log.txt";
	gLog->Open(logfile.c_str());
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	gGameManager->SetResourceRoot(gFileUtils->getWritablePath());
	gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
	gGameManager->CreateDirectory(gGameManager->GetLogPath());
	logfile = gGameManager->GetLogPath()+"/log.txt";
	gLog->Open(logfile.c_str());
#endif
	gGameManager->LogMachineInfo();
	// ø™ º∏¸–�?
	gGameManager->Start();

    return true;
}