c++ - What does that mean for "callfuncN_selector" in Cocos2dx? -
i want run first project in visual studio see appears have 2 errors, have no idea mean
void ccloud::start(){ this->stopallactions(); float currentx = this->getpositionx(); float distance = currentx - -(_xoffset); float time = distance / _pixelspersec; ccpoint destination = ccp(-_xoffset, this->getpositiony()); ccmoveto *actionmove = ccmoveto::create(time, destination); cccallfuncn *actionmovedone = cccallfuncn::create(this, callfuncn_selector(ccloud::reacheddestionation)); this->runaction(ccsequence::create(actionmove, actionmovedone, null)); }
and 2 errors are:
error 1 error c2440: 'type cast' : cannot convert 'void (__thiscall ccloud::* )(void)' 'cocos2d::sel_callfuncn'
c:\users\sergi_000\downloads\cocos2d-x-2.2.3\projects\myfirstapp\classes\ccloud.cpp 27 1 hellocpp
error 2 error c2665: 'cocos2d::cccallfuncn::create' : none of 2 overloads convert argument types
c:\users\sergi_000\downloads\cocos2d-x-2.2.3\projects\myfirstapp\classes\ccloud.cpp 27 1 hellocpp
i pleased if me, thanks!
a pointer member function not same pointer non-member function. pointer member function needs instance called on.
the usual solution library have callbacks allows 1 set kind of "user data", can set object instance. create callback wrapper function, static
member function (which can used normal non-member function pointer), , in user data, cast correct class, , call function want call.
caveat: don't know if cocos2d-x supports user-data callbacks.
Comments
Post a Comment