Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.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
Iphone 重新启动CCDIrector导致异常错误_Iphone_Cocos2d Iphone - Fatal编程技术网

Iphone 重新启动CCDIrector导致异常错误

Iphone 重新启动CCDIrector导致异常错误,iphone,cocos2d-iphone,Iphone,Cocos2d Iphone,我正在尝试重新启动游戏的CCDirector。但我有错误 所有这些都是我菜单中的代码[我的菜单包含XIB]: - (void) retryGame:(NSNotification *)notif { [menu2Game.view removeFromSuperview]; [[CCDirector sharedDirector] end]; [[CCDirector sharedDirector] release]; [self startGame:play]

我正在尝试重新启动游戏的CCDirector。但我有错误

所有这些都是我菜单中的代码[我的菜单包含XIB]:

- (void) retryGame:(NSNotification *)notif {
    [menu2Game.view removeFromSuperview];
    [[CCDirector sharedDirector] end];
    [[CCDirector sharedDirector] release];

    [self startGame:play];
}
它给了我和EXC糟糕的访问权限。就在我做两次的时候。第一个很好用

但如果移除

[self startGame:play];
我将返回到菜单,我点击按钮播放,我可以无限次,它的工作

我的朋友就这样放弃了,我不工作,我试了20次

- (void) quitGame:(NSNotification *)notif {
    [menu2Game.view removeFromSuperview];
    [[CCDirector sharedDirector] end];
    [[CCDirector sharedDirector] release];

    //Restart Animations
    [logo setFrame:CGRectMake(239, 119, 1, 1)];
    [play setFrame:CGRectMake(-233, play.frame.origin.y, play.frame.size.width, play.frame.size.height)];
    [options setFrame:CGRectMake(-233, options.frame.origin.y, options.frame.size.width, options.frame.size.height)];
    [extras setFrame:CGRectMake(-233, extras.frame.origin.y, extras.frame.size.width, extras.frame.size.height)];
    [GC setFrame:CGRectMake(0, 300, 1, 1)];

    [self viewDidLoad];
}
//在我的视图中,我只有动画

有什么问题吗?我试着延迟[perfomselector]完成,但问题是一样的。。。只要我返回菜单并单击“播放”,我就可以再次播放。无论速度如何,您都可以单击播放、暂停、退出、播放、暂停、退出等。。。游戏进行得很完美


谢谢

CCDirector是单身汉,您不应该发送发布消息

[[CCDirector sharedDirector] release];
不那样做完全没关系。值得一提的是,CCDirector startAnimation和stopAnimation是暂时停止Cocos2D的更可行的方法。

同样的问题

- (void) retryGame:(NSNotification *)notif {
    [menu2Game.view removeFromSuperview];
    [[CCDirector sharedDirector] end];
    //[[CCDirector sharedDirector] release];

    [self startGame:play];
}
开始比赛

 - (IBAction)startGame:(id)sender {


    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(quitGame:) name:@"quitGame" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(retryGame:) name:@"retryGame" object:nil];

    CCDirector *director = [CCDirector sharedDirector];

    // Init the View Controller
    menu2Game = [[Menu2Game alloc] initWithNibName:@"Menu2Game" bundle:nil];
    menu2Game.wantsFullScreenLayout = YES;

    //
    // Create the EAGLView manually
    //  1. Create a RGB565 format. Alternative: RGBA8
    //  2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition
    //
    //
    EAGLView *glView = [EAGLView viewWithFrame:[self.view bounds]
                                   pixelFormat:kEAGLColorFormatRGB565   // kEAGLColorFormatRGBA8
                                   depthFormat:0                        // GL_DEPTH_COMPONENT16_OES
                        ];

    // attach the openglView to the director
    [director setOpenGLView:glView];

    // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
    //  if( ! [director enableRetinaDisplay:YES] )
    //      CCLOG(@"Retina Display Not supported");


    [director setAnimationInterval:1.0/60];
    [director setDisplayFPS:YES];


    // make the OpenGLView a child of the view controller
    [menu2Game setView:glView];

    // make the View Controller a child of the main window
    [self.view addSubview: menu2Game.view];

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
    // You can change anytime.
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

    // Assusme PVR images have the alpha channel premultiplied
    [CCTexture2D PVRImagesHavePremultipliedAlpha:YES];

    // Run the intro Scene
    if ([director runningScene] == NULL) {
        [[CCDirector sharedDirector] runWithScene:[Game scene]];
    }else{
        [[CCDirector sharedDirector] replaceScene:[Game scene]];
    }
}
如果我评论[自我启动游戏];错误永远不会出现

哦,阿佩尔斯在这里

CCTextureAtlas.m[Cocos 2d]

#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
    glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(indices_[0])) );
#else
    glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(indices_[0])) );

我有同样的问题,我会发布更多信息。。。谢谢