我在景觀縱向兩個視圖其中之一是和其他。默認方向是風景。當我使用更改科科斯二維方向在橫向到縱向
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight];
雖然顯卡是完全旋轉從橫向更改視圖肖像,我在使用觸摸屏的問題。任何人都可以請幫我解決這個問題嗎?
我在景觀縱向兩個視圖其中之一是和其他。默認方向是風景。當我使用更改科科斯二維方向在橫向到縱向
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight];
雖然顯卡是完全旋轉從橫向更改視圖肖像,我在使用觸摸屏的問題。任何人都可以請幫我解決這個問題嗎?
這是那麼容易,解決了我的問題,通過剛剛轉換的接觸點,GL
CGPoint convertedLocation = [[CCDirector sharedDirector]convertToGL:point];
您是否使用了最新的cocos2d的模板?爲什麼[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight];
是行不通的原因是因爲在默認情況下,它可以讓UIKit (RootViewController)
來處理旋轉,讀取線77的評論 - 84.你的代碼不會被改變CCDirector
方向,而不是RootViewController
因此您的觸摸位置沒有被翻譯正常。
你用cocos2d的混合蘋果標準的UIKit?如果你沒有一個很簡單的辦法是隻去GameConfig.h
改變這些線路
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationUIViewController
到
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationCCDirector
PS更改自動旋轉處理程序可能/可能不取決於工作你如何設置你的項目。
它的簡單,非常簡單的實現正確的方向。您只需編輯您的RootViewController實現:只需修改它的-willChangeToInterfaceOrientation ...方法即可在您的應用程序中爲您的方向返回「YES」。例如,對於所有posibilities的返回值更改爲
return ((interfaceOrientation == UIInterfaceOrientationPortrait) ||
(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
上述工作完成後,如果它在橫向到縱向你的應用程序將只轉動。而你的應用程序(在這種情況下)只支持縱向。 要正確自轉您的應用程序響應從縱向到portraitUpsideDown(反之亦然)只改變編輯以下行與appropiate值配置CCDirector實例:
if(interfaceOrientation == UIInterfaceOrientationPortrait) {
[[CCDirector sharedDirector] setDeviceOrientation:
kCCDeviceOrientationPortraitUpsideDown];
} else if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[[CCDirector sharedDirector] setDeviceOrientation:
kCCDeviceOrientationPortrait];
}
所有這一切都在附帶的評論中提到您從您的模板項目中實現默認方法!
而且不要忘記編輯您的應用程序的Info.plist以包含鍵appropiate值 -InitialInterfaceOriatation -SupportedInterfaceOrientations
你通常不需要在您的應用程序委託類也不GameConfig改變什麼。H。
而且......你去那裏!
[startUpOptions的setObject:CCScreenOrientationPortrait forKey:CCSetupScreenOrientation];
我剛纔添加了上述代碼的appdelegate。(BOOL)應用程序中的m文件:(UIApplication *)應用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions和它的工作
touch screen? – Haroon 2012-01-27 13:40:33
這不是幀邊界定義的問題嗎? – Kheldar 2012-01-27 13:41:11
@哈羅恩:我認爲他是指活躍區域? – Kheldar 2012-01-27 13:41:35