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;
CCScenepScene = 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.