2012-08-28 10:22:36 +08:00
|
|
|
#ifndef __JS_COCOS2D_X_SPECIFICS_H__
|
|
|
|
#define __JS_COCOS2D_X_SPECIFICS_H__
|
|
|
|
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "ScriptingCore.h"
|
|
|
|
|
2012-11-01 02:08:37 +08:00
|
|
|
class JSScheduleWrapper;
|
2012-10-23 02:07:23 +08:00
|
|
|
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
// JSScheduleWrapper* --> CCArray* since one js function may correspond to many targets.
|
|
|
|
// To debug this, you could refer to JSScheduleWrapper::dump function.
|
|
|
|
// It will prove that i'm right. :)
|
2012-10-23 02:07:23 +08:00
|
|
|
typedef struct jsScheduleFunc_proxy {
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
JSObject* jsfuncObj;
|
|
|
|
CCArray* targets;
|
2012-10-23 02:07:23 +08:00
|
|
|
UT_hash_handle hh;
|
|
|
|
} schedFunc_proxy_t;
|
|
|
|
|
|
|
|
typedef struct jsScheduleTarget_proxy {
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
CCNode* nativeObj;
|
|
|
|
CCArray* targets;
|
2012-10-23 02:07:23 +08:00
|
|
|
UT_hash_handle hh;
|
|
|
|
} schedTarget_proxy_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct jsCallFuncTarget_proxy {
|
|
|
|
void * ptr;
|
|
|
|
CCArray *obj;
|
|
|
|
UT_hash_handle hh;
|
|
|
|
} callfuncTarget_proxy_t;
|
|
|
|
|
|
|
|
extern schedFunc_proxy_t *_schedFunc_target_ht;
|
|
|
|
extern schedTarget_proxy_t *_schedTarget_native_ht;
|
|
|
|
|
|
|
|
extern callfuncTarget_proxy_t *_callfuncTarget_native_ht;
|
2012-08-28 10:22:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* You don't need to manage the returned pointer. They live for the whole life of
|
|
|
|
* the app.
|
|
|
|
*/
|
|
|
|
template <class T>
|
|
|
|
inline js_type_class_t *js_get_type_from_native(T* native_obj) {
|
|
|
|
js_type_class_t *typeProxy;
|
2012-10-12 15:41:45 +08:00
|
|
|
long typeId = cocos2d::getHashCodeByString(typeid(*native_obj).name());
|
2012-08-28 10:22:36 +08:00
|
|
|
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
|
|
|
|
if (!typeProxy) {
|
2012-10-12 15:41:45 +08:00
|
|
|
cocos2d::TypeInfo *typeInfo = dynamic_cast<cocos2d::TypeInfo *>(native_obj);
|
2012-08-28 10:22:36 +08:00
|
|
|
if (typeInfo) {
|
|
|
|
typeId = typeInfo->getClassTypeInfo();
|
|
|
|
} else {
|
2012-10-12 15:41:45 +08:00
|
|
|
typeId = cocos2d::getHashCodeByString(typeid(T).name());
|
2012-08-28 10:22:36 +08:00
|
|
|
}
|
|
|
|
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
|
|
|
|
}
|
|
|
|
return typeProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The returned pointer should be deleted using JS_REMOVE_PROXY. Most of the
|
|
|
|
* time you do that in the C++ destructor.
|
|
|
|
*/
|
|
|
|
template<class T>
|
|
|
|
inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) {
|
|
|
|
js_proxy_t *proxy;
|
|
|
|
HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy);
|
|
|
|
if (!proxy) {
|
|
|
|
js_type_class_t *typeProxy = js_get_type_from_native<T>(native_obj);
|
|
|
|
assert(typeProxy);
|
|
|
|
JSObject* js_obj = JS_NewObject(cx, typeProxy->jsclass, typeProxy->proto, typeProxy->parentProto);
|
|
|
|
JS_NEW_PROXY(proxy, native_obj, js_obj);
|
|
|
|
#ifdef DEBUG
|
|
|
|
JS_AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name());
|
|
|
|
#else
|
|
|
|
JS_AddObjectRoot(cx, &proxy->obj);
|
|
|
|
#endif
|
|
|
|
return proxy;
|
|
|
|
} else {
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string);
|
|
|
|
void register_cocos2dx_js_extensions(JSContext* cx, JSObject* obj);
|
|
|
|
|
2012-11-01 02:08:37 +08:00
|
|
|
|
|
|
|
class JSCallbackWrapper: public CCObject {
|
2012-08-28 10:22:36 +08:00
|
|
|
public:
|
2012-11-01 15:45:22 +08:00
|
|
|
JSCallbackWrapper() : jsCallback(JSVAL_VOID), jsThisObj(JSVAL_VOID), extraData(JSVAL_VOID) {}
|
2012-11-01 02:08:37 +08:00
|
|
|
virtual ~JSCallbackWrapper(void) {}
|
2012-08-28 10:22:36 +08:00
|
|
|
void setJSCallbackFunc(jsval obj);
|
|
|
|
void setJSCallbackThis(jsval thisObj);
|
2012-11-01 02:08:37 +08:00
|
|
|
void setJSExtraData(jsval data);
|
|
|
|
|
2012-12-03 15:31:52 +08:00
|
|
|
const jsval& getJSCallbackFunc() const;
|
|
|
|
const jsval& getJSCallbackThis() const;
|
|
|
|
const jsval& getJSExtraData() const;
|
2012-11-01 02:08:37 +08:00
|
|
|
protected:
|
|
|
|
jsval jsCallback;
|
|
|
|
jsval jsThisObj;
|
|
|
|
jsval extraData;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class JSCCBAnimationWrapper: public JSCallbackWrapper {
|
|
|
|
public:
|
|
|
|
JSCCBAnimationWrapper() {}
|
|
|
|
virtual ~JSCCBAnimationWrapper() {}
|
|
|
|
|
|
|
|
void animationCompleteCallback() const {
|
|
|
|
|
|
|
|
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
|
|
|
jsval retval = JSVAL_NULL;
|
|
|
|
|
|
|
|
if(!JSVAL_IS_VOID(jsCallback) && !JSVAL_IS_VOID(jsThisObj)) {
|
|
|
|
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(jsThisObj), jsCallback, 0, NULL, &retval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class JSCallFuncWrapper: public JSCallbackWrapper {
|
|
|
|
public:
|
|
|
|
JSCallFuncWrapper() {}
|
|
|
|
virtual ~JSCallFuncWrapper(void) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setTargetForNativeNode(CCNode *pNode, JSCallFuncWrapper *target);
|
2012-10-23 02:07:23 +08:00
|
|
|
static CCArray * getTargetForNativeNode(CCNode *pNode);
|
|
|
|
|
2012-11-05 18:44:28 +08:00
|
|
|
void callbackFunc(CCNode *node) const;
|
2012-08-28 10:22:36 +08:00
|
|
|
};
|
|
|
|
|
2012-10-10 05:59:16 +08:00
|
|
|
|
2012-11-01 02:08:37 +08:00
|
|
|
class JSScheduleWrapper: public JSCallbackWrapper {
|
2012-10-10 05:59:16 +08:00
|
|
|
|
|
|
|
public:
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
JSScheduleWrapper() : m_pTarget(NULL) {}
|
2012-11-01 02:08:37 +08:00
|
|
|
virtual ~JSScheduleWrapper() {
|
2012-10-23 02:07:23 +08:00
|
|
|
return;
|
|
|
|
}
|
2012-10-10 05:59:16 +08:00
|
|
|
|
2012-11-01 02:08:37 +08:00
|
|
|
static void setTargetForSchedule(jsval sched, JSScheduleWrapper *target);
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
static CCArray * getTargetForSchedule(jsval sched);
|
2012-11-01 02:08:37 +08:00
|
|
|
static void setTargetForNativeNode(CCNode *pNode, JSScheduleWrapper *target);
|
2012-10-10 05:59:16 +08:00
|
|
|
static CCArray * getTargetForNativeNode(CCNode *pNode);
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
static void removeAllTargetsForNatiaveNode(CCNode* pNode);
|
|
|
|
static void dump();
|
2012-10-10 05:59:16 +08:00
|
|
|
|
|
|
|
void pause();
|
|
|
|
|
2012-11-22 12:05:38 +08:00
|
|
|
void scheduleFunc(float dt) const;
|
issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
|
|
|
CCObject* getTarget();
|
|
|
|
void setTarget(CCObject* pTarget);
|
|
|
|
protected:
|
|
|
|
CCObject* m_pTarget;
|
2012-10-10 05:59:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-28 10:22:36 +08:00
|
|
|
class JSTouchDelegate: public CCTouchDelegate, public CCNode {
|
|
|
|
public:
|
|
|
|
void setJSObject(JSObject *obj);
|
|
|
|
void registerStandardDelegate();
|
|
|
|
void registerTargettedDelegate(int priority, bool swallowsTouches);
|
|
|
|
|
|
|
|
bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouch);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
jsval retval;
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHBEGAN,
|
|
|
|
pTouch, _mObj, retval);
|
|
|
|
if(JSVAL_IS_BOOLEAN(retval)) {
|
|
|
|
return JSVAL_TO_BOOLEAN(retval);
|
|
|
|
} return false;
|
|
|
|
};
|
|
|
|
// optional
|
|
|
|
|
|
|
|
void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouch);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
2012-09-24 13:57:45 +08:00
|
|
|
//jsval retval;
|
2012-08-28 10:22:36 +08:00
|
|
|
ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHMOVED,
|
|
|
|
pTouch, _mObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouch);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHENDED,
|
|
|
|
pTouch, _mObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouch);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHCANCELLED,
|
|
|
|
pTouch, _mObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// optional
|
|
|
|
void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouches);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchesEvent(CCTOUCHBEGAN,
|
|
|
|
pTouches, _mObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouches);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchesEvent(CCTOUCHMOVED,
|
|
|
|
pTouches, _mObj);
|
|
|
|
}
|
|
|
|
void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouches);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchesEvent(CCTOUCHENDED,
|
|
|
|
pTouches, _mObj);
|
|
|
|
}
|
|
|
|
void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) {
|
|
|
|
CC_UNUSED_PARAM(pTouches);
|
|
|
|
CC_UNUSED_PARAM(pEvent);
|
|
|
|
ScriptingCore::getInstance()->executeCustomTouchesEvent(CCTOUCHCANCELLED,
|
|
|
|
pTouches, _mObj);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
JSObject *_mObj;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|