At the end of my scene init I delay call a function after 0.1 seconds to allow the window to display. In this function I load lots of data from a binary file so I update the width of a sprite loading bar every so often while reading data then do CCDirector::sharedDirector()->drawScene(); to force a render update to see the sprite size change. This works, however after the data load is done the original actionWithTarget executes again. Is this a bug or do you have a better way?
bool MainLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF( !CCLayerColor::initWithColor( ccc4( 0, 0, 0, 255 ) ) );
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
bRet = true;
} while (0);
// This should only run once, but it runs over and over
this->runAction( CCSequence::actions(CCDelayTime::actionWithDuration(0.1f),CCCallFunc::actionWithTarget(this, callfunc_selector(MainLayer::LoadData)),NULL));
return bRet;
}
void MainLayer::LoadData()
{
...load some data
...update width of loading bar
CCDirector::sharedDirector()->drawScene();
...load some more data
...update width of loading bar
CCDirector::sharedDirector()->drawScene();
...keep loading data
}
The load function does actually display the updated progress bar size, but like I said, when it’s done the LoadData function is run over and over again even though I am not loading the scene or layer again.