Ejemplo n.º 1
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.º 2
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.º 3
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* director = Director::getInstance();
    EGLView* glView = EGLView::getInstance();

    director->setOpenGLView(glView);
    
    Size size = director->getWinSize();

	setDesignResolution();

    // Set the design resolution
	glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.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
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	Scene *scene = MainTitleScene::create();
#else
    Scene *scene = HelloWorld::scene();
#endif
    // run
    director->runWithScene(scene);

    return true;
}
Ejemplo n.º 4
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.º 5
0
void SceneManager::changeScene( EnumSceneType enScenType, bool isTrans, float time )
{
    Scene* pScene = getSceneByType(enScenType);
    
    if(pScene == NULL)
    {
        return;
    }
    //TextureCache::sharedTextureCache()->removeUnusedTextures();
    Director* pDirector = Director::getInstance();
    Scene* curScene = pDirector->getRunningScene();
    if(curScene == NULL)
    {
        pDirector->runWithScene(pScene);
    }
    else
    {
        if(isTrans)
        {
            pDirector->replaceScene(TransitionFade::create(time, pScene));
        }
        else
        {
            pDirector->replaceScene(pScene);
        }
    }
}
Ejemplo n.º 6
0
bool CGameSceneManager::go(SCENE_TYPE st)
{
    Scene* scene = nullptr;
    switch (st)
    {
        case ST_LOGIN:
        {
            CCBReader* pReader = new CCBReader(NodeLoaderLibrary::getInstance());
            scene = pReader->createSceneWithNodeGraphFromFile("login_layer.ccbi");
            delete pReader;
            break;
        }
        case ST_LOBBY:
        {
            CCBReader* pReader = new CCBReader(NodeLoaderLibrary::getInstance());
            scene = pReader->createSceneWithNodeGraphFromFile("lobby_layer.ccbi");
            delete pReader;
            break;
        }
        case ST_FORMATION:
        {
            scene = Scene::create();
            scene->addChild(CFormationLayer::create());
            break;
        }
        case ST_BATTLE_FIELD:
        {
            scene = Scene::create();
            scene->addChild(CBattleFieldLayer::create());       // call init in create()
            break;
        }
        case ST_SETTINGS:
            break;
        case ST_HOME:
        {
            CCBReader* pReader = new CCBReader(NodeLoaderLibrary::getInstance());
            scene = pReader->createSceneWithNodeGraphFromFile("home_layer.ccbi");
            delete pReader;
            break;
        }
        default:
            break;
    }
    if (scene)
    {
        Director* pDirector = Director::getInstance();
        if (pDirector->getRunningScene())
        {
            TransitionFade* trans = TransitionFade::create(.2f, scene, Color3B(255, 255, 255));
            pDirector->replaceScene(trans);
        }
        else
        {
            pDirector->runWithScene(scene);
        }
    }
    
    return true;
}
Ejemplo n.º 7
0
bool FrameManager::Init()
{
    RegisterAllFrame();
    mCurScene = Scene::create();
    Director* director = Director::getInstance();
    director->runWithScene(mCurScene);
    return true;
}
Ejemplo n.º 8
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.º 9
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director *pDirector = Director::sharedDirector();

    pDirector->setOpenGLView(EGLView::sharedOpenGLView());

    Size screenSize = EGLView::sharedOpenGLView()->getFrameSize();
    //Size designSize = CCSizeMake(1600, 900);
    Size designSize = CCSizeMake(12*101, 12*81);
    std::vector<std::string> searchPaths;

    if (screenSize.height > 320)
    {
        searchPaths.push_back("hd");
        searchPaths.push_back("sd");
        Size resourceSize = CCSizeMake(12*101, 12*81);
        //pDirector->setContentScaleFactor(960.0f/designSize.height);
        ///pDirector->setContentScaleFactor(1.0f);
        pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
    }
    else
    {
        searchPaths.push_back("sd");
        pDirector->setContentScaleFactor(640.0f/designSize.height);
    }

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

    EGLView::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);

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

    if (_levelToLaunch == nullptr)
    {
        scene = MainMenuLayer::scene();
    }
    else
    {
        auto ms = Bomber::Frontend::MenuSelections::getInstance();
        ms->setLevelFilename(_levelToLaunch);
        ms->setLevelName("test");
        scene = GameplayScene::scene();
    }

    // run
    pDirector->runWithScene(scene);

    return true;
}
Ejemplo n.º 10
0
void SceneManager::go(Layer* layer)
{
    Director *director = Director::getInstance();
    Scene *newScene = SceneManager::wrap(layer);
    if ( director->getRunningScene() )
    {
        s_nSceneIdx++;
        s_nSceneIdx = s_nSceneIdx % MAX_LAYER;
        Director::getInstance()->replaceScene(createTransition(s_nSceneIdx, TRANSITION_DURATION, newScene));
    }
    else
    {
        director->runWithScene(newScene);
    }
}
Ejemplo n.º 11
0
void SceneManager::go(Scene* scene)
{
	Layer* layer = (Layer*)scene;

	Director *director = Director::getInstance();
	Scene *newScene = SceneManager::wrap(layer);
	if ( director->getRunningScene() )
	{
		director->replaceScene(newScene);
	}
	else
	{
		director->runWithScene(newScene);
	}
}
Ejemplo n.º 12
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.º 13
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.º 14
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.º 15
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.º 16
0
bool CGameSceneManager::go(SCENE_TYPE st)
{
    Scene* scene = nullptr;
    switch (st)
    {
        case ST_LOGIN:
        {
            scene = CCBReadHelper::readScene("login_layer.ccbi");
            break;
        }
        case ST_LOBBY:
        {
            scene = CCBReadHelper::readScene("lobby_layer.ccbi");
            break;
        }
        case ST_MATCH:
        {
            scene = CCBReadHelper::readScene("pitch_layer.ccbi");
            break;
        }
        default:
            break;
    }
    if (scene)
    {
        Director* pDirector = Director::getInstance();
        if (pDirector->getRunningScene())
        {
            TransitionFade* trans = TransitionFade::create(.2f, scene, Color3B(255, 255, 255));
            pDirector->replaceScene(trans);
        }
        else
        {
            pDirector->runWithScene(scene);
        }
    }
    
    return true;
}
Ejemplo n.º 17
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;
}