2017-04-18 26 views
0

我有多屏幕解決方案的問題。我已經完成了搜索,但仍然無法找到解決方案,因爲這些答案被喧賓奪主/使用已棄用的方法或對我不清楚。經過3個小時的搜索並嘗試了許多不同的建議,我仍然無法完成它,我感到困惑,所以我必須創建這個主題。非常感謝您的關注和幫助。我的工作是designResolutionSize = cocos2d::Size(1280, 720);。它可以在我的電腦顯示器上正常工作(屏幕解決方案爲1600x900),但是當我在機頂盒上安裝我的應用程序並在30英寸或40英寸電視機上運行時。我的小精靈不能放大以適應電視屏幕,它們看起來太小了。如何縮放我的精靈上/下取決於cocos2dx中的屏幕分辨率?

我的問題我應該如何讓我的應用比例放大/縮小取決於設備分辨率,以適應屏幕?

我AppDelegate.cpp:

static cocos2d::Size designResolutionSize = cocos2d::Size(1280, 720); 

bool AppDelegate::applicationDidFinishLaunching(){ 
    // Get the Director instance 
    auto mDirector = Director::getInstance(); 
    // Get the GL View Container 
    auto mGLView = mDirector->getOpenGLView(); 
     //Set up View Container if there's no available one 
    if (!mGLView) 
    { 
     mGLView = GLViewImpl::create("NGTV Launcher"); 
     /*mGLView->setFrameSize(1280, 720);*/ 
     mGLView->setFrameSize(1600, 900); 
     /*mGLView->setFrameSize(1920, 1080);*/ 
     mDirector->setOpenGLView(mGLView); 
    } 

    mGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::EXACT_FIT); 
    // Innitialize a Scene with createScene() 
    auto mScene = HelloWorld::createScene(); 
    // Run the scenee 
    mDirector->runWithScene(mScene); 

    return true; 
} 
+1

你應該擴大你的精靈。如果'kYourSpriteScale == 1'精靈將會是屏幕的大小,那麼你可以通過調整屏幕大小來調整屏幕尺寸。 – Darvydas

+0

嗨@Darvydas,謝謝你的建議。但是,有沒有更好的方法來根據屏幕大小自動縮放我的App?由於我的應用程序在這裏和那裏都有很多精靈聲明,因此在如此龐大的源代碼中逐個縮放它們需要很多努力。這對後來的維護代碼也不好。 –

+1

其實我並不知道,我總是根據設備的大小來調整和定位一切。還有不同的長寬比呢?你將如何處理? – Darvydas

回答