在使用kResolutionShowAll的cocos2dx中,如何使用空边框?

时间:2013-12-31 11:42:11

标签: cocos2d-x screen-resolution

我即将用cocos2d-x开发一款Android游戏,我遇到了一些解决方案问题。 我正在使用kResolutionShowAll解析策略来确保我的所有图像都显示在设备中。 但是我在一些设备上有一个很大的边界,我想找到一种方法用图像,广告或其他任何东西来填充这些边界。

我发现了这个:http://www.cocos2d-x.org/forums/6/topics/20512?r=21066但它并没有真正起作用。

我不知道我是否选择了错误的政策,也许我应该选择kResolutionNoBorder。或许我误解了一些关于解决方案的问题,而且我的方法不正确。

2 个答案:

答案 0 :(得分:0)

For the support for all devices you can use following code:
**Landscape Mode**

bool AppDelegate::applicationDidFinishLaunching()
    {

        // initialize director
        director = CCDirector::sharedDirector();
        EGLView  = CCEGLView::sharedOpenGLView();

        director->setOpenGLView(EGLView);


        CCSize screenSize = EGLView->getFrameSize();
        CCSize designSize = CCSizeMake(800, 480);
        EGLView->setDesignResolutionSize(designSize.width,designSize.height, kResolutionExactFit);


        if(screenSize.height > 480 && screenSize.height < 720 )
        {

            CCSize resourceSize = CCSizeMake(960, 540);
            director->setContentScaleFactor(resourceSize.height/screenSize.height);
            CCLog("Resolution Scale OF Karboon=%f",resourceSize.width/screenSize.width);
        }


        else if (screenSize.height >= 720 && screenSize.height < 800)
        {

            CCSize resourceSize = CCSizeMake(1280, 720);
            director->setContentScaleFactor(resourceSize.height/screenSize.height);
            CCLog("Resolution Scale OF NOTE=%f",resourceSize.width/screenSize.width);

        }

        else if(screenSize.height > 800)
        {
            CCSize resourceSize = CCSizeMake(1920, 1080);
            director->setContentScaleFactor(resourceSize.height/screenSize.height);
            CCLog("Resolution Scale OF Nexus=%f",resourceSize.width/screenSize.width);

        }

        else
        {


         director->setContentScaleFactor(1);
        CCLog("Resolution Scale OF S Advance=%f");

        }

答案 1 :(得分:-3)

In the AppDelegate.cpp you can try this.

// initialize director



    CCDirector*  director = CCDirector::sharedDirector();
    CCEGLView*  EGLView  = CCEGLView::sharedOpenGLView();

    director->setOpenGLView(EGLView);


    CCSize screenSize = EGLView->getFrameSize();
    CCSize designSize = CCSizeMake(800, 480);
    EGLView->setDesignResolutionSize(designSize.width,designSize.height, kResolutionExactFit);