I used targetTouchdelegate for my nodes, cc.registerTargettedDelegate(priority, swallowsTouches, node);
In simulator, it’s all ok. but when I run it in ipad, it always crashed here.
/////
bool JSTouchDelegate::ccTouchBegan(CCTouch pTouch, CCEventpEvent) {
CC_UNUSED_PARAM(pEvent);
jsval retval;
bool bRet = false;
js_proxy_t* p = jsb_get_js_proxy(_mObj);
CCAssert(p, “js object has been unrooted.”);
I’ve solved my problem
because I use cocosbulder, so I have to use cc.cc.registerTargettedDelegate like this:cc.registerTargettedDelegate(cc.MENU_HANDLER_PRIORITY, true, this.rootNode);
previously, I lost .rootNode
Or maybe you should use
this.rootNode.setTouchPriority(priority);
this.rootNode.setTouchMode(cc.TOUCHES_ONE_BY_ONE);
instead of
cc.registerTargettedDelegate(priority, swallowsTouches, node);
I noticed that if I use cc.registerTargettedDelegate in onDidLoadFromCCB, it will call addTargetedDelegate(this,priority,swallowsTouches); in cocos2d_specifics.cpp
But when this layer call onEnter in c++, it will call registerWithTouchDispatcher and finally will call addTargetedDelegate again.
So, addTargetedDelegate actually called twice with the same layer. If I use the 2 line code at start it works OK!
I used targetTouchdelegate for my nodes, cc.registerTargettedDelegate(priority, swallowsTouches, node);
In simulator, it’s all ok. but when I run it in ipad, it always crashed here.
/////
bool JSTouchDelegate::ccTouchBegan(CCTouch pTouch, CCEventpEvent) {
CC_UNUSED_PARAM(pEvent);
jsval retval;
bool bRet = false;
>
js_proxy_t* p = jsb_get_js_proxy(_mObj);
CCAssert(p, “js object has been unrooted.”);
>
ScriptingCore::getInstance()->executeCustomTouchEvent(CCTOUCHBEGAN,
pTouch, _mObj, retval);
if(JSVAL_IS_BOOLEAN(retval)) {
bRet = JSVAL_TO_BOOLEAN(retval);
}
>
return bRet;
};
>
p is null ptr. who can tell me how to resolve it?
My version is 2.1.4