1,进入这三个源码中,可以看到这几句代码分别为
typedef voID (CCobject::*SEL_SCHEDulE)(float); //函数指针,函数有一个参数float,返回类型为voID
typedef voID (CCobject::*SEL_CallFunc)();//函数指针,函数无参数,返回类型为voID
typedef voID (CCobject::*SEL_CallFuncN)(CCNode*)//函数指针,函数有一个参数,返回类型为voID
typedef voID (CCobject::*SEL_CallFuncND)(CCNode*,voID*);/函数指针,函数有一个参数,返回类型为voID
typedef voID (CCobject::*SEL_CallFuncND)(CCNode*,voID*);/函数指针,函数有两个参数,返回类型为voID
typedef voID (CCobject::*SEL_CallFuncO)(CCObject*);/函数指针,函数有一个参数,返回类型为voID
typedef voID (CCObject::SEL_MenuHandler)(CCObject*);// 函数指针,函数有一个参数,返回类型为voID
2,这些都是Cocos2dx中定义的宏
#define schedule_selector(_SELECTOR) (SEL_SCHEDulE)(&_SELECTOR)
#define callfunc_selector(_SELECTOR) (SEL_CallFunc)(&_SELECTOR)
#define callfuncN_selector(_SELECTOR) (SEL_CallFuncN)(&_SELECTOR)
#define callfuncND_selector(_SELECTOR) (SEL_CallFuncND)(&_SELECTOR)
#define callfuncO_selector(_SELECTOR) (SEL_CallFuncO)(&_SELECTOR)
#define menu_selector(_SELECTOR) (SEL_MenuHandler)(&_SELECTOR)
3,下面看一些经常使用的方法voID Daojishi(float dt);//必须要有参数才能调用update
我们可能都会用到,如 this->schedule(schedule_selector(myTest::Daojishi));
voID add(CCobject * pSender);
或者item->setTarget(menu_selector(myTest::add));
CCNode * node
SEL_CallFuncND selectorND;// 函数指针
或者 CCObject *pSelectorTarget; SEL_SCHEDulE selector;
voID ArmatureSprite::ArmatureAttackcall(CCNode* _pNode1,SEL_CallFuncND _pselector1,voID *_pd1,149)">CCNode* _pNode2,149)">SEL_CallFuncND _pselector2,166)">voID* _pd2){
pNode1 = _pNode1;
pSelector1 = _pselector1;
pD1 = _pd1;
pNode2 = _pNode2;
pSelector2 = _pselector2;
pD2 = _pd2;
_armatureBaoZha->ArmatureAttackcall(NulL,NulL, NulL,this,callfuncND_selector(BaseSpecialEffectsGetReward::HD_OpenStarBox),tempStr);
}
menu_selector(HelloWorld::menuCloseCallback));
Object::*SEL_Cal
总结以上是内存溢出为你收集整理的cocos2dx 中的SEL_Callfunc,SEL_CallfuncN,SEL_CallfuncNd的用法全部内容,希望文章能够帮你解决cocos2dx 中的SEL_Callfunc,SEL_CallfuncN,SEL_CallfuncNd的用法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)