CCScriptEventDispatcher(quick扩展类 。用于lua 下的CCNode 事件分发)
来源:互联网 发布:vue安装sass淘宝镜像 编辑:程序博客网 时间:2024/05/16 12:47
#ifndef __CCSCRIPT_EVENT_DISPATCHER_H__
#define __CCSCRIPT_EVENT_DISPATCHER_H__
#include <map>
#include <vector>
#include "CCObject.h"
using namespace std;
NS_CC_BEGIN
class CC_DLL CCScriptHandlePair
{
public:
int index;
int listener;
int tag;
int priority;
bool enabled;
CCScriptHandlePair(int index_,int listener_,int tag_,int priority_)
: index(index_)
, listener(listener_)
, tag(tag_)
, priority(priority_)
, enabled(true)
{
}
};
#define NODE_EVENT 0
#define NODE_ENTER_FRAME_EVENT 1
#define NODE_TOUCH_EVENT 2
#define NODE_TOUCH_CAPTURE_EVENT 3
#define MENU_ITEM_CLICKED_EVENT 4
#define ACCELERATE_EVENT 5
#define KEYPAD_EVENT 6
#define NODE_TOUCH_CAPTURING_PHASE 0
#define NODE_TOUCH_TARGETING_PHASE 1
// listener handle -> listener pair
typedef vector<CCScriptHandlePair> CCScriptEventListenersForEvent;
typedef CCScriptEventListenersForEvent::iterator CCScriptEventListenersForEventIterator;
// event -> CCScriptEventListenersForEvent
typedef map<int, CCScriptEventListenersForEvent> CCScriptEventListenersForDispatcher;
typedef CCScriptEventListenersForDispatcher::iterator CCScriptEventListenersForDispatcherIterator;
class CC_DLL CCScriptEventDispatcher :public CCObject
{
public:
CCScriptEventDispatcher();
virtual ~CCScriptEventDispatcher();
int addScriptEventListener(int event,int listener,int tag =0,int priority =0);
void removeScriptEventListener(int handle);
void removeScriptEventListenersByEvent(int event);
void removeScriptEventListenersByTag(int tag);
void removeAllScriptEventListeners();
bool hasScriptEventListener(int event);
CCScriptEventListenersForEvent &getScriptEventListenersByEvent(int event)const;
CCScriptEventListenersForDispatcher &getAllScriptEventListeners()const;
private:
CCScriptEventListenersForDispatcher *m_scriptEventListeners;
staticint s_nextScriptEventHandleIndex;
static CCScriptEventListenersForEvent s_emptyListenersForEvent;
static CCScriptEventListenersForDispatcher s_emptyListeners;
staticbool sortListenerCompare(const CCScriptHandlePair &a,const CCScriptHandlePair &b);
staticbool removeListenerByTag(CCScriptHandlePair &p);
staticint s_removeTag;
};
NS_CC_END
#endif // __CCSCRIPT_EVENT_DISPATCHER_H__
- CCScriptEventDispatcher(quick扩展类 。用于lua 下的CCNode 事件分发)
- 请教一个 quick Cocos2dx Lua扩展 protobuf的问题
- android下的事件分发
- quick-lua touch 触摸事件
- quick-cocos2dx lua语言讲解 (动作,定时器,触摸事件,工程的类的讲解)
- quick-cocos2d-x lua 触摸事件、操作文件的实例
- quick cocos2dx-Lua中的自定义事件的使用
- quick-cocos2dx在eclipse下的lua调试
- quick-cocos2dx在eclipse下的lua调试
- quick-cocos2dx在eclipse下的lua调试
- Android下的Touch事件分发
- 探索LUA用于API级的测试中(用C对Lua进行扩展)
- android事件分发下
- Android事件分发下
- 事件分发下
- xcode下lua扩展库的编译
- [寒江孤叶丶的Cocos2d-x之旅_23]Cocos2d-x LUA实现事件分发器 lua EventDispatcher
- View的事件体系(下)(事件分发,滑动冲突)
- 读取drawable文件夹的图片(根据文件名)
- 如何用 OS X 的 Xcode 写 C 语言程序
- <frameset>和<body>不能共用
- 积跬步,聚小流-------js实现placeholder的效果
- string字符串 获取指定位置范围的子字符串
- CCScriptEventDispatcher(quick扩展类 。用于lua 下的CCNode 事件分发)
- 编程语言的过去、现在和未来
- HTML5开发环境搭建
- JS基础——Cookie与存储
- Java对.properties文件(即java.util.Properties类)的一些操作
- Android Studio:Fetching android sdk component information问题
- iOS开发 - 百度地图后台持续定位
- UITableViewCell的重用
- Android应用正确使用扩展SD卡