Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocos2d游戏中心因方向问题导致iOS6崩溃_Ios_Cocos2d Iphone_Game Center - Fatal编程技术网

Cocos2d游戏中心因方向问题导致iOS6崩溃

Cocos2d游戏中心因方向问题导致iOS6崩溃,ios,cocos2d-iphone,game-center,Ios,Cocos2d Iphone,Game Center,在给出解决方案之前,这里已经提出了这个问题,但不能正常工作 检查这个,我也有同样的问题。上面链接中的代码解决了这个问题,GameCenter工作了,但是现在cocos2d游戏轮换了,这给游戏带来了问题。有没有人解决了这个问题,或者有什么解决办法 我也尝试过这个,但它没有像我想的那样工作,因为我使用的是cocos2d场景 目前我正在实现这段代码来解决这个问题,因为我别无选择 -(NSUInteger)application:(UIApplication*)application supported

在给出解决方案之前,这里已经提出了这个问题,但不能正常工作

检查这个,我也有同样的问题。上面链接中的代码解决了这个问题,GameCenter工作了,但是现在cocos2d游戏轮换了,这给游戏带来了问题。有没有人解决了这个问题,或者有什么解决办法

我也尝试过这个,但它没有像我想的那样工作,因为我使用的是cocos2d场景

目前我正在实现这段代码来解决这个问题,因为我别无选择

-(NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
我需要的解决方案是简单地打开gamecenter而不崩溃,同时锁定landscape方向的代码,将所有cocos2d场景保留在landscape中
任何帮助都将不胜感激。提前谢谢。

根据我的经验,我所做的大部分回答都在CoCoS2D1.x上解决了这个问题。然而,我的游戏是使用cocos2d 2.x开发的,因此以下是解决我问题的方法:

1我在目标设置中有以下设置:

人们说我应该增加肖像支持,但这只是搞砸了我的旋转

2确保您使用的是最新的cocos2d 2.x!即使它是在测试版!目前为v2.1 b2

相信我,我有很多错误和头痛,因为我认为beta是不稳定的,我没有使用它。最终,与Xcode不同,cocos2d始终建议升级到beta版

3在AppDelegate.m中,确保您没有使用CCDirector方法,这些方法运行于场景:和pushScene:inside-BOOLapplication:didFinishLaunchingWithOptions:

您要做的是仅使用此功能:

// This is needed for iOS4 and iOS5 in order to ensure
// ... blah blah blah
- (void)directorDidReshapeProjection:(CCDirector *)director {
    if (director.runningScene == nil) {
        // Add the first scene to the stack. blah blah...
        // and add blah
        [director runWithScene:[LanguageScene node]];
    }
}

只是猜测一下,不要在-BOOLapplication:didfishlaunchingwithoptions:中验证玩家。在加载主场景后对他进行身份验证,并调用OneInterTransitiondFinish。

根据我的经验,我在cocos2d 1.x上给出的大多数答案都解决了这个问题。然而,我的游戏是使用cocos2d 2.x开发的,因此以下是解决我问题的方法:

1我在目标设置中有以下设置:

人们说我应该增加肖像支持,但这只是搞砸了我的旋转

2确保您使用的是最新的cocos2d 2.x!即使它是在测试版!目前为v2.1 b2

相信我,我有很多错误和头痛,因为我认为beta是不稳定的,我没有使用它。最终,与Xcode不同,cocos2d始终建议升级到beta版

3在AppDelegate.m中,确保您没有使用CCDirector方法,这些方法运行于场景:和pushScene:inside-BOOLapplication:didFinishLaunchingWithOptions:

您要做的是仅使用此功能:

// This is needed for iOS4 and iOS5 in order to ensure
// ... blah blah blah
- (void)directorDidReshapeProjection:(CCDirector *)director {
    if (director.runningScene == nil) {
        // Add the first scene to the stack. blah blah...
        // and add blah
        [director runWithScene:[LanguageScene node]];
    }
}

只是猜测一下,不要在-BOOLapplication:didfishlaunchingwithoptions:中验证玩家。在加载主场景后对其进行身份验证,并调用OneInterTransitiondFinish。

我终于让Game Center在iOS 6中工作,并为我保留了锁定的场景

我将此代码放在AppDelegate中。不是viewcontroller

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  return (UIInterfaceOrientationMaskAll);
}
我把它放在我的视图控制器中

- (void)authenticateLocalPlayer {
     GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
     localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
    {
        if (viewController != nil)
        {
            [self presentViewController:viewController animated:YES completion:nil];  
        }
     };
}
我还发现了排行榜和成就视图控制器的更新

[self presentViewController:achievements animated:YES completion:nil];
[self presentViewController:leaderboardController animated:YES completion:nil];

[self dismissViewControllerAnimated:NO completion:nil];

我终于让Game Center在iOS 6中工作,并为我保留了锁定的环境

我将此代码放在AppDelegate中。不是viewcontroller

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  return (UIInterfaceOrientationMaskAll);
}
我把它放在我的视图控制器中

- (void)authenticateLocalPlayer {
     GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
     localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
    {
        if (viewController != nil)
        {
            [self presentViewController:viewController animated:YES completion:nil];  
        }
     };
}
我还发现了排行榜和成就视图控制器的更新

[self presentViewController:achievements animated:YES completion:nil];
[self presentViewController:leaderboardController animated:YES completion:nil];

[self dismissViewControllerAnimated:NO completion:nil];

您使用的是cocos2d 1.x还是2.x?此答案可能会对您有所帮助。请尝试为方法应用程序返回UIInterfaceOrientationMaskLandscape支持InterfaceOrientationsForWindow您使用的是CoCoCoS2D 1.x还是2.x?此答案可能会对您有所帮助。请尝试为方法应用程序返回UIInterfaceOrientationMaskLandscapeSupportedInterfaceDirectionsforWindow将尝试此操作并告诉您操作过程。我们将尝试此操作并告诉您操作过程