0

I have a UISplitviewController app that's structured like the picture in this question:

UISplitViewController on iPad with Storyboards?

When I click on either Game #1 or Game #2, their respective game run. However, if I click on the second game (either #1 or #2), I get this error:

Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'You can't run an scene
if another Scene is running. Use replaceScene or pushScene instead'

How can I check to see if there's already an existing Cocos2d scene and replace it when the second game is clicked? Ideally, I think I should keep both games running so the user can click back to the other game. Is this possible?

I tried to simply replace this line: [director runWithScene:scene];

with this line: [director replaceScene:scene];

Unfortunately, I get an error CCTextureAtlas.m, in method:

-(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start {...}

enter image description here

[Update]

I think I might need to stop the scene so everything is cleaned up properly. When I click on my Help screen, for example, my controller's viewWillDisappear gets called. This does not happen when switching between Cocos2d view controllers.


After following these instructions, and only creating the EAGLView once, I almost have it working, but I get a black screen for the second scene. Note that I do briefly see the new scene.

Community
  • 1
  • 1

1 Answers1

0

How can I check to see if there's already an existing Cocos2d scene and replace it when the second game is clicked?

if ([[CCDirector sharedDirector] runningScene] == nil) {
        [[CCDirector sharedDirector] runWithScene:sceneToRun];
    } else {
        [[CCDirector sharedDirector] replaceScene:sceneToRun];
    }
Kreiri
  • 7,840
  • 5
  • 30
  • 36
  • This gives the same error that I got when I tried to replace the scene. I included a picture. Maybe it's an ARC issue? I think I have Cocos2d 1.1 beta. –  May 23 '12 at 01:50
  • Do you do anything else to handle multiple scenes, like only creating the EAGLView once? See my updates. Thanks. –  May 31 '12 at 02:45