2014-11-21 114 views
1

我正在使用cocoas2d-x V3.0。我試圖如何獲得iPhone 6或6 Plus的確切屏幕尺寸

Size screenSize = CCDirector::getInstance()->getWinSizeInPixels(); 

但它返回一個iPhone 5(640 * 1136)的大小,而我在iPhone 6或iPhone 6plus模擬器測試。

+1

是它在Xcode 6或者您正在嘗試做6,6+兼容舊版本中創建一個新的項目:

這個問題已經在這個環節被人們津津樂道? – Smile 2014-11-21 08:47:25

+1

v3.0可能不知道關於iPhone 6,請嘗試最新版本 – LearnCocos2D 2014-11-21 08:50:45

+0

@ismail是啊我在xcode 6.1中創建了一個新項目。 – 2014-11-21 08:57:10

回答

0

您需要獲取cocos2d-x v3.3,因爲之前版本的cocos2d-x沒有獲得iPhone 6和iPhone 6 plus的正確屏幕分辨率,因爲他們仍然認爲比例因子是2而不是3,因此返回iPhone 5的分辨率。 https://github.com/cocos2d/cocos2d-x/issues/8545

0
You need to add Launch images for Iphone 6 & 6+ , only then 
it will show you its real screen size. 

Go to your Xcode -> Select Target -> Select General -> 
select Launch Image Source under App Icons & Launch Images . 

Now you can add there your launch images for iphone 6 & plus 
which could be 1334*750 & 2208*1242 For landScape mode. 

Now you can have your device screenSize with following code . 

Size WinSize= Director::getInstance()->getWinSize(); 

i have faced same thing in my project & this way i solved it. 
i am using Xcode 6 & cocos2d-x 3.2 

I hope this helps.