转载请标明:转载自【小枫栏目】,博文链接http://blog.csdn.net/my183100521/article/details/10231311
CCSprite *RoleMan = CCSprite::create("Role.png"); RoleMan->setPosition(ccp(60, size.height/2)); this->addChild(RoleMan); RoleMan->setVisible(false); CCFiniteTimeAction* action = CCSequence::create( CCPlace::create(ccp(200,200)), CCShow::create(), CCMoveBy::create(1, ccp(100,0)), CCCallFunc::create(this,callfunc_selector(HelloWorld::callback1)), CCCallFuncN::create(this,callfuncN_selector(HelloWorld::callback2)), CCCallFuncND::create(this,callfuncND_selector(HelloWorld::callback3),(void*)0xbebabeba), NULL); RoleMan->runAction(action);回调方法
void HelloWorld::callback1() { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*1,s.height/2)); addChild(label); } void HelloWorld::callback2(CCNode* sender) { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*2,s.height/2)); addChild(label); } void HelloWorld::callback3(CCNode* sender, void* data) { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16); label->setPosition(ccp( s.width/4*3,s.height/2)); addChild(label); }