| cocos2d-x 3.0 |
)- 类列表 - 类索引 - 类继承关系 - 类成员
全部) 类) 命名空间) 文件) 函数) 变量) 类型定义) 枚举) 枚举值) 属性) 友元) 宏定义) 组) 页)
Public 成员函数 | 静态 Public 成员函数 | Public 属性 | Protected 属性 | 友元 | 所有成员列表
EventListenerCustom类 参考
用法: auto dispatcher = Director::getInstance()->getEventDispatcher(); 添加一个监听器: 更多…
#include
类 EventListenerCustom 继承关系图:
| ## Public 成员函数 | |
| virtual bool | checkAvailable () override |
| 重写 更多… | |
| virtual EventListenerCustom | clone () override |
| 克隆监听器(listener),它的子类必须重写此. 更多… | |
| bool | init (const ListenerID &listenerId, const std::function< void(EventCustom )> &callback) |
| 指定事件类型和回调函数初始化事件监听器 更多… | |
Public 成员函数 继承自 EventListener | |
| virtual | ~EventListener () |
| 析构函数 更多… | |
| void | setEnabled (bool enabled) |
| 启用或禁用监听器(listener) 更多… | |
| bool | isEnabled () const |
| 检查监听器是否可用 更多… | |
Public 成员函数 继承自 Ref | |
| void | retain () |
| 保留所有权. 更多… | |
| void | release () |
| 立即释放所有权. 更多… | |
| Ref * | autorelease () |
| 自动释放所有权在不久的将来. 更多… | |
| unsigned int | getReferenceCount () const |
| 返回Ref对象当前的引用计数. 更多… | |
| virtual | ~Ref () |
| NA NA 更多… | |
| ## 静态 Public 成员函数 | |
| static EventListenerCustom | create (const std::string &eventName, const std::function< void(EventCustom )> &callback) |
| 指定事件类型和回调函数创建一个事件监听器. 更多… | |
| ## Public 属性 | |
| CC_CONSTRUCTOR_ACCESS | pad0: EventListenerCustom() |
| ## Protected 属性 | |
| std::function< void(EventCustom )> | _onCustomEvent |
Protected 属性 继承自 EventListener | |
| std::function< void(Event )> | _onEvent |
| Type | _type |
| 事件回调函数 更多… | |
| ListenerID | _listenerID |
| Event listener 事件监听器的类型 更多… | |
| bool | _isRegistered |
| Event listener 事件监听器的ID. 更多… | |
| int | _fixedPriority |
| 监听器(listener)是否被加入到派发器(dispatcher) . 更多… | |
| Node * | _node |
| bool | _paused |
| bool | _isEnabled |
Protected 属性 继承自 Ref | |
| unsigned int | _referenceCount |
| 引用计数 更多… | |
| ## 友元 | |
| class | LuaEventListenerCustom |
| ## 额外继承的成员函数 | |
Public 类型 继承自 EventListener | |
| enum | Type { UNKNOWN, TOUCH_ONE_BY_ONE, TOUCH_ALL_AT_ONCE, KEYBOARD, MOUSE, ACCELERATION, FOCUS, CUSTOM } |
| typedef std::string | ListenerID |
Protected 成员函数 继承自 EventListener | |
| EventListener () | |
| 构造函数 更多… | |
| bool | init (Type t, const ListenerID &listenerID, const std::function< void(Event )> &callback) |
| 使用 事件类型和回调函数 初始化事件 更多… | |
| void | setPaused (bool paused) |
| 设置监听器的暂停状态 暂停状态仅被用于场景图像优先级监听器. 更多… | |
| bool | isPaused () const |
| 检查监听器是否被暂停 更多… | |
| void | setRegistered (bool registered) |
| 标记监听器已经被加入到事件派发器(EventDispatcher) 更多… | |
| bool | isRegistered () const |
| 检查监听器是否被注册到事件派发器(EventDispatcher) 更多… | |
| Type | getType () const |
| 获取监听器(listener)的类型 更多… | |
| const ListenerID & | getListenerID () const |
| 获取监听器的ID 当事件派发,监听器ID是用于查找符合事件类型的监听器的关键字. 更多… | |
| void | setFixedPriority (int fixedPriority) |
| 为监听器设置固定优先级 更多… | |
| int | getFixedPriority () const |
| 获取监听器的优先级 更多… | |
| void | setAssociatedNode (Node node) |
| 设置和监听器关联的节点 更多… | |
| Node * | getAssociatedNode () const |
| 获取和监听器关联的节点 更多… | |
Protected 成员函数 继承自 Ref | |
| Ref () | |
| 构造函数 更多… | |
详细描述
用法: auto dispatcher = Director::getInstance()->getEventDispatcher(); 添加一个监听器:
auto callback = { do_some_thing(); }; auto listener = EventListenerCustom::create(callback); dispatcher->addEventListenerWithSceneGraphPriority(listener, one_node);
派发一个自定义事件:
EventCustom event("your_event_type"); dispatcher->dispatchEvent(&event);
移除一个监听器
dispatcher->removeEventListener(listener);
成员函数说明
| overridevirtual |
重写
实现了 EventListener.
| overridevirtual |
克隆监听器(listener),它的子类必须重写此.
实现了 EventListener.
| static |
指定事件类型和回调函数创建一个事件监听器.
- 参数
eventType事件类型. callback特定的事件被触发时执行该回调函数.
| bool init | ( | const ListenerID & | listenerId, |
| const std::function< void(EventCustom *)> & | callback | ||
| ) |
指定事件类型和回调函数初始化事件监听器
友元及相关函数文档
| friend |
类成员变量说明
| CC_CONSTRUCTOR_ACCESS pad0 |
| protected |
该类的文档由以下文件生成:
- /Users/zeroyang/Documents/github/cocos2d-x/cocos/base/CCEventListenerCustom.h
- cocos2d
- EventListenerCustom
- 生成于 2014年 五月 29日 星期四 09:41:45 , 为 cocos2d-x使用
1.8.6
Public 成员函数 继承自 