CCCallFuncN :: create(this,callfuncN_selector(DressMe_LevelManager :: removeTheObjectFromArray)),NULL));在cocos3.9中给出错误

时间:2016-01-04 04:04:08

标签: ios c++11 cocos2d-x

ActionInterval *scale1 = ScaleTo::create(.05f, 1.3f);
ActionInterval *scale2 = ScaleTo::create(.1f, 0.0f); 
runAction(CCSequence::create(
    scale1,
    scale2,
    CCDelayTime::create(.8f),
    CCCallFuncN::create(this,callfuncN_selector(DressMe_LevelManager::removeTheObjectFromArray)),
NULL)); 


void DressMe_LevelManager:: removeTheObjectFromArray(DressMe_objectClass *l_obj){
    m_ptrArrayElements->removeObject(l_obj);
    l_obj = NULL;
    MoveBakTheCart();
}

我收到此错误:

static_cast from void (DressMe_LevelManager::*) (Dress_ObjectClass *) to cocos2d::SEL_CallfuncN (aka void (cocos2d:Ref::*) (cocos2d::Node *) ) is not allowed

1 个答案:

答案 0 :(得分:0)

更改操作如下:

runAction(CCSequence::create(
                                 scale1,
                                 scale2,
                                 CCDelayTime::create(.8f),
                                 CallFuncN::create(CC_CALLBACK_1(HelloWorld::removeTheObjectFromArray, this)),
                                 NULL));

不推荐使用callfuncN_selector,它接受​​具有Node*类型参数的函数。因此当removeTheObjectFromArray接受Dress_ObjectClass的对象时,它会出错。