Texture loading flicker while switching scenes

Hi all,

I have two scenes - MainScene and GameScene.
On both init method I create CCSpriteBatchNode and use it in the scene.
When switching from MainScene to GameScene using:

CCTransitionScene transition = CCTransitionFade::create);
CCDirector::sharedDirector->replaceScene;
I get some flickering, showing me the texture I’m using for the GameScene and then showing the GameScene properly.
When I create the GameScene in AppDelegate, like I did with MainScene, everything works well, I guess because it something to do with caching the textures. But this way I have to load all the textures for all the scenes in the beginning.
Some code:
In the end of AppDelegate::applicationDidFinishLaunching I do:
GameScene::scene;
CCScene
pScene = StoryScene::scene();
pDirector->runWithScene(pScene);

In the beginning of MainScene::init I do:

m_pBatchNode = CCSpriteBatchNode::create(“main.pvr”);
addChild(m_pBatchNode);
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“main.plist”);

In the beginning of GameScene::init I do:

m_pBatchNode = CCSpriteBatchNode::create(“game.pvr”);
addChild(m_pBatchNode);
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“game.plist”);

And when I switch from MainScene to GameScene (by handling touch-up event):

CCTransitionScene *transition = CCTransitionFade::create(1.0f, GameScene::scene());
CCDirector::sharedDirector()->replaceScene(transition);

I want to be able to load the textures just when I need them per scene.

Please help.

try to change CCDirector’s projection to 2D (default is in 3D).

Don’t know how it should help in this situation, but I tried:

CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->setProjection(cocos2d::ccDirectorProjection::kCCDirectorProjection2D);

Didn’t work…

When you said flickering i understood that you had a problem i had some time before (texture flickered between scenes), but now that i read it better i see that’s not the same (oops!).

You should try to reduce your example to the minimum, discard all elements that don’t have anything to do with the problem (transitions, maybe?); you’ll have to make some tests to find out.
Right now i see too many noise to understand the question right away.

You should also try to create a dummy scene that only does this:
addChild(CCSpriteBatchNode::create("main.pvr"));
And see if that shows the full texture you’re seeing or not.

As said, find and remove unrelated code and ask again :slight_smile:

I’m having the same issue. Did you manage to solve it?