how to make UI adapt to big screen?


#1

I run the demo in wp8 720p screen ,it has problem , the UI can not adapt to the big screen (you can see the attachment), I find some code below, but may not work.
Is there a way to solve the problem.

bool AppDelegate::initInstance()
{
    bool bRet = false;
    do 
    {

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN8_METRO)

    // fix bug: 16bit aligned
    void* buff=_aligned_malloc(sizeof(CCEGLView),16);
    CCEGLView* mainView = new (buff) CCEGLView();
    mainView->Create();
    //mainView->setDesignResolution(480, 320);
    //mainView->setDesignResolution(640, 1066);
    CCLOG("Device Res:%d", m_deviceResolutionInPixels);
    switch (m_deviceResolutionInPixels) 
    {
    case DeviceResolutionInPixels_WVGA: 
        {
            mainView->setDesignResolution(480, 800);
            break;
        }
    case DeviceResolutionInPixels_720p: 
        {
            mainView->setDesignResolution(720, 1280);
            break;
        }   
    case DeviceResolutionInPixels_WXGA: 
        {
            mainView->setDesignResolution(768, 1280);
            break;
        }
    }


#endif // CC_PLATFORM_WIN8_METRO

        bRet = true;
    } while (0);
    return bRet;
}


111.png (227.3 KB)


#2

Hey,
I had similar problem and hacked it so it works pretty good now.
This is how you do it:
go to CCEGLVIEW_win8_metro.cpp
# delete “factor = 1” around line 153 function setViewPortInPoints();
# change

float winWidth = render->m_window->Bounds.Width;
float winHeight = render->m_window->Bounds.Height;

m_fScreenScaleFactor = min(winWidth / dx, winHeight / dy);
m_fScreenScaleFactor *= CCDirector::sharedDirector()->getContentScaleFactor();  

at line 212 to

float resolutionScale = ((int)Windows::Graphics::Display::DisplayProperties::ResolutionScale) / 100.0f;
float winWidth = render->m_window->Bounds.Width * resolutionScale;      
float winHeight = render->m_window->Bounds.Height * resolutionScale;
m_fScreenScaleFactor = min(winWidth / dx, winHeight / dy);

Please let me now if there’s any problem with it, I may have forgotten something.


#3

Jan Ivanecky wrote:

Hey,
I had similar problem and hacked it so it works pretty good now.
This is how you do it:
go to CCEGLVIEW_win8_metro.cpp
# delete “factor = 1” around line 153 function setViewPortInPoints();
# change
>
[…]
>
at line 212 to
[…]
>
Please let me now if there’s any problem with it, I may have forgotten something.

thanks for the reply, I try what you say , but the problem still exist.


#4

Hello:
I have the similar problem and i want to know what’s the “m_deviceResolutionInPixels” and how can i get it .
i can’t find the definition of DeviceResolutionInPixels_WVGA …
please help me .
thanks!