如何延迟一个动作(或)如何控制程序流等待特定动作完成

How to delay an action (or) How to control program flow to wait for a particular action to complete

我有这样的代码。

我必须将精灵移动到特定位置,完成该操作后,我想将其删除。

但它是在不执行操作的情况下删除它。怎么做到的。

sp 是精灵

sp->runAction(MoveTo::create(1.0, Vec2(visibleSize.width/2, visibleSize.height/2)));
this->removeChild(sp);
auto move = MoveTo::create(1.0, Vec2(visibleSize.width/2, visibleSize.height/2));
auto moveDone = CallFuncN( CC_CALLBACk_1(ClassName::removeSprite, this) );
sp->runAction( Sequence::create( move, moveDone, NULL ) );

//create a function removeSprite, it will be called after action move is finished
void ClassName::removeSprite(Node* pNode) {

pNode->removeFromParent();
}