void HelloWorld::startMovingBackground() {
CCLog("startMovingBackground...");
if ( isLeftPressed && isRightPressed ) {
return;
}
CCLog("schedule..."); // OK.......................
this->schedule(schedule_selector(HelloWorld::moveBackground));
}
和
void HelloWorld::moveBackground(float f) {
CCLog("moveBackground %f", f); // NO....................
// Do move background...
}
但是, 不调用moveBackground函数。帮帮我...
=============================================== ===========
代码(初始化“HelloScene”)
CCScene* HelloWorld::scene() {
CCScene * scene = NULL;
do {
scene = CCScene::create();
CC_BREAK_IF(! scene);
HelloWorld *layer = HelloWorld::create();
CC_BREAK_IF(! layer);
scene->addChild(layer);
} while (0);
return scene;
}
bool HelloWorld::init()
{
bool bRet = false;
do {
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) );
this->setTouchEnabled(true);
winSize = CCDirector::sharedDirector()->getWinSize();
this->setTouchEnabled(true);
this->createBackgroundParallax();
this->createArrowButtons();
bRet = true;
} while (0);
return bRet;
}
答案 0 :(得分:1)
如果您调用onEnter
,scheduleUpdate()
可能无效。请尝试以下操作:
CCDirector::sharedDirector()->getScheduler()->scheduleUpdateForTarget(this,0,false);
或
CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(NewGame::update),this,0.1,false);
答案 1 :(得分:-2)
你错过了
中的争论this->schedule( selector, time_interval);
如果我没记错了,默认值为0,永远不会被调用。