2

我有一个表格视图,列出了我拥有的游戏地图。当我单击一个时,会加载另一个包含 cocos2d 场景的故事板。

我第一次加载场景时,一切都完美加载。但是,我第二次尝试加载场景(从导航控制器返回并单击同一张地图或另一张地图)时,我得到一个显示 fps 的空白屏幕,但没有其他内容。

这是我在 mapViewController 中的代码(包含 cocos2d)

    - (void)setupCocos3D { //called from viewDidLoad
    [[CCDirector sharedDirector] setOpenGLView:openGLView];  


    ((ViewInterface*)[ViewInterface sharedViewInterface]).currentScene = [testScene scene];


    // Create the customized CC3Layer that supports 3D rendering.
    CC3Layer* cc3Layer = [HelloWorldLayer node];

    // Create the customized 3D scene and attach it to the layer.
    // Could also just create this inside the customer layer.


    cc3Layer.cc3Scene =  ((ViewInterface*)[ViewInterface sharedViewInterface]).currentScene;

    // Assign to a generic variable so we can uncomment options below to play with the capabilities
    CC3ControllableLayer* mainLayer = cc3Layer;

    mainLayer.contentSize = CGSizeMake(2048, 1320);

    [CCDirector sharedDirector].animationInterval = (1.0f / kAnimationFrameRate);
    [CCDirector sharedDirector].displayStats = YES;
    [[CCDirector sharedDirector] enableRetinaDisplay: YES];

    ((ViewInterface*)[ViewInterface sharedViewInterface]).mainLayer = mainLayer;

    [[CCDirector sharedDirector] runWithScene:((ViewInterface*)[ViewInterface sharedViewInterface]).mainLayer];
}

- (void)viewWillDisappear:(BOOL)animated
{

    [super viewWillDisappear:animated];
    [[CCDirector sharedDirector] end];


}

我能看到 fps 真的很奇怪,因此似乎唯一的问题是场景或图层。

4

1 回答 1

0

是否保留了场景?它会被释放而不被重新创建吗?

于 2013-04-15T17:59:55.960 回答