码迷,mamicode.com
首页 > 其他好文 > 详细

Cocos2dx选择器

时间:2014-07-20 00:04:35      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:style   color   strong   os   re   c   

今天学习cocos2dx的时候发现原来所有选择器要求传递的回调函数的参数是有限制的,看了库中的定义后就遇到的整理如下,仅供参考,Cocos2dx版本2.2.3:

?

选择器参数说明

schedule_selector(浮点数)[float dt]

?

callfunc_selector(无参数)[void]

?

callfuncn_selector(节点)[CCNode *node]

?

callfuncND_selector(节点,任意参数)[CCNode *node,void *any]

?

callfuncO_selector(对象)[CCObject *pSender]

?

menu_selector(对象)[CCObject *pSender]

?

event_selector(事件)[CCEvent *event]

?

compare_selector(对象)[CCObject *pSender]

?

?

原始的声明如下

typedef void (CCObject::*SEL_SCHEDULE)(float);

typedef void (CCObject::*SEL_CallFunc)();

typedef void (CCObject::*SEL_CallFuncN)(CCNode*);

typedef void (CCObject::*SEL_CallFuncND)(CCNode*, void*);

typedef void (CCObject::*SEL_CallFuncO)(CCObject*);

typedef void (CCObject::*SEL_MenuHandler)(CCObject*);

typedef void (CCObject::*SEL_EventHandler)(CCEvent*);

typedef int (CCObject::*SEL_Compare)(CCObject*);

?

对应选择器宏

#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)

#define event_selector(_SELECTOR) (SEL_EventHandler)(&_SELECTOR)

#define compare_selector(_SELECTOR) (SEL_Compare)(&_SELECTOR)

?

?

?

cccontrol_selector(对象,整数)[CCObject *pSender,CCControlEvent]

?

原始声明如下:

typedef unsigned int CCControlEvent;

?

typedef void (CCObject::*SEL_CCControlHandler)(CCObject*, CCControlEvent);

?

对应选择器宏:

#define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR)

Cocos2dx选择器,布布扣,bubuko.com

Cocos2dx选择器

标签:style   color   strong   os   re   c   

原文地址:http://www.cnblogs.com/lhyz/p/3855633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!