2

I have a table view that lists the game maps I have. When I click on one, another storyboard loads containing a cocos2d scene.

The first time I load a scene, everything loads perfectly. However, the second time I try to load the scene (back from the navigation controller and clicking on the same map or another one), I get a blank screen showing the fps but nothing else.

here's my code in mapViewController (that contains the 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];


}

It is really strange that I can see the fps therefore it seems that the only problem is either with the scene or the layer.

Etienne Noël
  • 5,988
  • 6
  • 48
  • 75

1 Answers1

0

Is the scene being retained? Could it be getting released and not being re-created?

Mike C.
  • 601
  • 3
  • 8