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;
}
Esempio n. 2
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;
}
Esempio n. 3
0
void MyQGLWidget::resizeGL(int w, int h)
{
    if (Display::IsRetinaDisplay())
    {
        w >>= 1;
        h >>= 1;
    }

    if (!mLazyInit)
    {
        mLazyInit = true;

        EGLView* view = EGLView::sharedOpenGLView();
        view->setFrameSize(w, h);

        Director* director = Director::sharedDirector();
        director->setContentScaleFactor(1);
        director->setProjection(kDirectorProjection2D);
        //director->setDisplayStats(true);
        director->setOpenGLView(view);

        connect(&mTimer, SIGNAL(timeout()), this, SLOT(updateGL()));
        mTimer.start();

        Scene* scene = Scene::create();
        director->pushScene(scene);

        setMouseTracking(true);
    }

    EGLView* view = EGLView::sharedOpenGLView();
    view->setFrameSize(w, h);
    view->setDesignResolutionSize(w, h, kResolutionNoBorder);
}
Esempio n. 4
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;
}
Esempio n. 5
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;
}
Esempio n. 6
0
    void MultiResolution::resolve()
    {
        EGLView *eglView = EGLView::getInstance();
        Size rsize;
        const Size fsize = eglView->getFrameSize();
        const bool v = fsize.height / fsize.width > 1.0f;
        const Size size = swap(fsize, v);
        const Size dsize = swap(Size(960, 640), v);

        std::vector<std::string> order;

        ApplicationProtocol::Platform platform = Application::getInstance()->getTargetPlatform();
        if(platform == ApplicationProtocol::Platform::OS_IPHONE || platform == ApplicationProtocol::Platform::OS_IPAD)
        {
            if(size.height > 768)
            {
                rsize.setSize(2048, 1536);
                order.push_back(names[static_cast<int>(ResolutionType::iPadHD)]);
            }
            else if(size.height > 640)
            {
                rsize.setSize(1536, 768);
                order.push_back(names[static_cast<int>(ResolutionType::iPad)]);
            }
            else if(size.height > 480)
            {
                if(size.width < 1136)
                    rsize.setSize(960, 649);
                else
                    rsize.setSize(1136, 640);
                order.push_back(names[static_cast<int>(ResolutionType::iPhoneHD)]);
            }
            else
            {
                rsize.setSize(480, 320);
                order.push_back(names[static_cast<int>(ResolutionType::iPhone)]);
            }
        }
        else if(platform == ApplicationProtocol::Platform::OS_ANDROID)
        {
            if(size.height > 1200)
            {
                rsize.setSize(1200, 800);
                order.push_back(names[static_cast<int>(ResolutionType::XLarge)]);
            }
            else if(size.height > 960)
            {
                rsize.setSize(960, 640);
                order.push_back(names[static_cast<int>(ResolutionType::Large)]);
            }
            else if(size.height > 480)
            {
                rsize.setSize(720, 480);
                order.push_back(names[static_cast<int>(ResolutionType::Medium)]);
            }
            else
            {
                rsize.setSize(568, 320);
                order.push_back(names[static_cast<int>(ResolutionType::Small)]);
            }
        }

        rsize = swap(rsize, v);
        Director::getInstance()->setContentScaleFactor(dsize.width / rsize.width);
        eglView->setDesignResolutionSize(rsize.width, rsize.height,/* kResolutionFixedHeight */ ResolutionPolicy::SHOW_ALL);
        FileUtils::getInstance()->setSearchPaths(searchPaths);
        FileUtils::getInstance()->setSearchResolutionsOrder(order);
    }