我的代码是这样的。
我必须将一个精灵移动到特定的位置,在完成该动作后,我想删除它。
但它正在删除它而不执行操作。如何实现这一点。
sp是精灵
sp->runAction(MoveTo::create(1.0, Vec2(visibleSize.width/2, visibleSize.height/2)));
this->removeChild(sp);
答案 0 :(得分:0)
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();
}