CCLayer Init being called mutliple times

Hi,

Until today my android game was working ok. I have been implementing an SQLite DB in the Java part of the project.

I fired up the game as usual, selected a level from the main menu, and noticed the level kept resetting itself to the start state. I looked in the log, and found that the init() was being called every few seconds, so waht I was actually getting was new levels on top of the old.

I’ve been hunting for hours now trying to find out why this might happen. I have changed nothing in the C++ code from what was a working game yesterday - it’s even had a few weeks of beta testing by my testing group.

What could I have done in the Java part that causes the init() to be called again and again? Has anyone seen anything like this?

Like I said, my C++ code has not changed, but just in case, here is the change scene code which gave no problems so far:

void CGameManager::RunScene(int sceneNumber, int levelNum) {
	cocos2d::CCScene *pScene;
	
	switch (sceneNumber) {
		case kSceneAbout:
			pScene = CAboutLayer::scene();
			break;
		case kSceneHelp:
			pScene = CHelpLayer::scene();
			break;
		case kSceneMainMenu:
			pScene = CMainMenuLayer::scene();
			break;
		case kSceneStore:
			pScene = CStoreLayer::scene();
			break;
		case kSceneGameLayer:
			pScene = CGameLayer::scene(levelNum);
			break;
		case kSceneSound:
			pScene = CVolumeLayer::scene();
			break;
		case kSceneSplash:
			pScene = CSplashLayer::scene();
			break;
		default:
			pScene = CMainMenuLayer::scene();
			break;
	}
	
	if(CCDirector::sharedDirector()->getRunningScene() == NULL) {
		CCDirector::sharedDirector()->runWithScene(pScene);
	} else {
		CCDirector::sharedDirector()->replaceScene(pScene);
	}
}

I have also stopped all JNI calls I do between the Java and C++, but no change.

Any pointers as to what could be the cause would be great.

**EDIT In fact, random scenes keep popping up. I’ve done something very wrong somewhere :slight_smile: Luckily I have 15min incremental backups, so I can always reset everything.

Thanks