2012-01-27 53 views
1

我在景观纵向两个视图其中之一是和其他。默认方向是风景。当我使用更改科科斯二维方向在横向到纵向

[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight]; 

虽然显卡是完全旋转从横向更改视图肖像,我在使用触摸屏的问题。任何人都可以请帮我解决这个问题吗?

+0

touch screen? – Haroon 2012-01-27 13:40:33

+0

这不是帧边界定义的问题吗? – Kheldar 2012-01-27 13:41:11

+0

@哈罗恩:我认为他是指活跃区域? – Kheldar 2012-01-27 13:41:35

回答

0

这是那么容易,解决了我的问题,通过刚刚转换的接触点,GL

CGPoint convertedLocation = [[CCDirector sharedDirector]convertToGL:point]; 
3

您是否使用了最新的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更改自动旋转处理程序可能/可能不取决于工作你如何设置你的项目。

1

它的简单,非常简单的实现正确的方向。您只需编辑您的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。

而且......你去那里!

0

[startUpOptions的setObject:CCScreenOrientationPortrait forKey:CCSetupScreenOrientation];

我刚才添加了上述代码的appdelegate。(BOOL)应用程序中的m文件:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions和它的工作

相关问题