0
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;
} 
4

2 回答 2

1

如果您调用onEnterscheduleUpdate()可能无法正常工作。请尝试以下操作:

CCDirector::sharedDirector()->getScheduler()->scheduleUpdateForTarget(this,0,false);

或者

CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(NewGame::update),this,0.1,false);
于 2013-12-24T06:30:07.290 回答
-2

你错过了一场争论

this->schedule( selector, time_interval);

如果我没记错的话,默认是 0,它永远不会被调用。

于 2013-03-28T02:00:18.120 回答