CCCallFunc和CCSequence

class CC_DLL CCCallFunc : public CCActionInstant //<NSCopying>

void Issue1305_2::onEnter()
{
    ActionsDemo::onEnter();
    centerSprites(0);

    CCSprite *spr = CCSprite::create("Images/grossini.png");
    spr->setPosition(ccp(200,200));
    addChild(spr);

    CCMoveBy* act1 = CCMoveBy::create(2 ,ccp(0, 100));
    //CCCallFunc也是动作,可以放到动作序列里
    CCCallFunc* act2 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log1)) ;
    CCMoveBy* act3 = CCMoveBy::create(2, ccp(0, -100));
    CCCallFunc* act4 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log2)) ;
    CCMoveBy* act5 = CCMoveBy::create(2, ccp(100, -100));
    CCCallFunc* act6 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log3)) ;
    CCMoveBy* act7 = CCMoveBy::create(2, ccp(-100, 0));
    CCCallFunc* act8 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log4)) ;

    CCFiniteTimeAction* actF = CCSequence::create(act1, act2, act3, act4, act5, act6, act7, act8, NULL);

    //    [spr runAction:actF];
    CCDirector::sharedDirector()->getActionManager()->addAction(actF ,spr, false);

}

void Issue1305_2::log1()
{
    CCLog("1st block");
}

void Issue1305_2::log2()
{
    CCLog("2nd block");
}

void Issue1305_2::log3()
{
    CCLog("3rd block");
}

void Issue1305_2::log4()
{
    CCLog("4th block");
}

 

你可能感兴趣的:(sequence)