void removeFromParentAndCleanup (bool cleanup)//刪除父節點中的當前節點並清除動作及回調函數
void ActionCallFuncND::onEnter() { ActionsDemo::onEnter(); centerSprites(1); CCFiniteTimeAction* action = CCSequence::create(CCMoveBy::create(2.0f, ccp(200,0)), CCCallFuncND::create(this, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true), NULL); m_grossini->runAction(action); } void ActionCallFuncND::removeFromParentAndCleanup(CCNode* pSender, void* data) { bool bCleanUp = data != NULL; m_grossini->removeFromParentAndCleanup(bCleanUp); }
//通過響應函數做永久動作
void ActionRepeatForever::onEnter() { ActionsDemo::onEnter(); centerSprites(1); CCFiniteTimeAction* action = CCSequence::create( CCDelayTime::create(1), CCCallFuncN::create( this, callfuncN_selector(ActionRepeatForever::repeatForever) ), NULL); m_grossini->runAction(action); } void ActionRepeatForever::repeatForever(CCNode* pSender) { CCRepeatForever *repeat = CCRepeatForever::create( CCRotateBy::create(1.0f, 360) ); pSender->runAction(repeat); }