收到内存警告。等级= 2。数据格式化程序暂时不可用,将在“继续”后重试

时间:2010-06-24 09:43:17

标签: cocoa-touch cocos2d-iphone

我正在使用cocos2d 0.99.4和Xcode 4.0。所以,我根据0.99.4版本中提供的文档和示例以这种方式更改了我的AppDelegate。

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [CCDirector setDirectorType:kCCDirectorTypeDisplayLink];
    CCDirector *director = [CCDirector sharedDirector];
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
    [director setAnimationInterval:1.0/60];
    [director setDisplayFPS:NO];
    EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
                               pixelFormat:kEAGLColorFormatRGBA8            
                               depthFormat:GL_DEPTH_COMPONENT24_OES   
                    preserveBackbuffer:NO];

    [[CCDirector sharedDirector] setOpenGLView:glView];

    [window addSubview:glView];
    [window makeKeyAndVisible]; 

    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
    gameLevel = [[NSUserDefaults standardUserDefaults] integerForKey:@"gameLevel"] ;
    gameLevel = 1;

    CCScene *scene = [CCScene node];
    CCLayer *layer = [GamewinScreen node];  
    [scene addChild :layer];

    [[CCDirector sharedDirector] runWithScene: scene];  

}  

//方法test1也在app Delegate类中。

 -(void)test1
{

    [[CCDirector sharedDirector] end];
    [[CCDirector sharedDirector] setOpenGLView:[[window subviews] objectAtIndex:0]];    

    CCScene *Scene = [CCScene node];
    CCLayer *Layer = [OpeningScreen node];

    [Scene addChild:Layer]; 

    [[CCDirector sharedDirector] runWithScene: Scene];
}

在GameWinScreen中我有一个选择器@selector(goToFirstScreen),

-(void)goToFirstScreen:(id)sender
{
    [MY_DELEGATE performSelector:@selector(test1) withObject:nil afterDelay:1.0];
 }   

在玩了50分钟以上的比赛后,我得到了

Received memory warning. Level=1  

超过10次然后是     收到内存警告。级别= 2

并且应用程序崩溃了。提供以下信息

Program received signal:  “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")

alt text http://www.freeimagehosting.net/uploads/52ac11fe93.png

alt text http://www.freeimagehosting.net/uploads/619333a82f.png

1 个答案:

答案 0 :(得分:1)

这是cocos2d告诉你你做错了什么。您正在setDirectorType的导演上致电goToFirstScreen,但第二次打电话给他时,已有导演。我不知道你为什么要重新启动导演。为什么不直接替换场景:

-(void)goToFirstScreen:(id)sender
{
    CCScene *Scene = [CCScene node];
    CCLayer *Layer = [OpeningScreen node];
    [Scene addChild:Layer];
    [[CCDirector sharedDirector] replaceScene:Scene];
}