mirror of https://github.com/axmolengine/axmol.git
Fixing CallFuncN bindings to properly pass optional third parameter
This commit is contained in:
parent
094d52664d
commit
5760ea305c
|
@ -48,7 +48,11 @@ var Bullet = cc.Sprite.extend({
|
|||
cc.ArrayRemoveObject(MW.CONTAINER.ENEMY_BULLETS,this);
|
||||
cc.ArrayRemoveObject(MW.CONTAINER.PLAYER_BULLETS,this);
|
||||
this.removeFromParentAndCleanup(true);
|
||||
var removeExplode = cc.CallFunc.create(explode,explode.removeFromParentAndCleanup);
|
||||
|
||||
var removeExplode = cc.CallFunc.create(explode, function(sender) {
|
||||
explode.removeFromParentAndCleanup(true);
|
||||
});
|
||||
|
||||
explode.runAction(cc.ScaleBy.create(0.3, 2,2));
|
||||
explode.runAction(cc.Sequence.create(cc.FadeOut.create(0.3), removeExplode));
|
||||
},
|
||||
|
|
|
@ -554,8 +554,7 @@ void JSCallFunc::setJSCallbackThis(jsval thisObj) {
|
|||
}
|
||||
|
||||
void JSCallFunc::setExtraDataField(jsval data) {
|
||||
extraData = new jsval();
|
||||
*extraData = data;
|
||||
extraData = data;
|
||||
}
|
||||
|
||||
void JSCallFunc::setTargetForNativeNode(CCNode *pNode, JSCallFunc *target) {
|
||||
|
|
|
@ -82,7 +82,7 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* obj);
|
|||
class JSCallFunc: public CCObject {
|
||||
public:
|
||||
JSCallFunc(jsval func): jsCallback(func) {}
|
||||
JSCallFunc() { extraData = NULL; }
|
||||
JSCallFunc() {}
|
||||
virtual ~JSCallFunc() {
|
||||
return;
|
||||
}
|
||||
|
@ -102,16 +102,15 @@ public:
|
|||
js_proxy_t *proxy = js_get_or_create_proxy<cocos2d::CCNode>(cx, node);
|
||||
|
||||
valArr[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
|
||||
if(extraData != NULL) {
|
||||
valArr[1] = *extraData;
|
||||
if(!JSVAL_IS_NULL(extraData)) {
|
||||
valArr[1] = extraData;
|
||||
} else {
|
||||
valArr[1] = JSVAL_NULL;
|
||||
}
|
||||
|
||||
jsval retval;
|
||||
if(jsCallback != JSVAL_VOID || jsThisObj != JSVAL_VOID) {
|
||||
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(jsThisObj), jsCallback, 1, valArr, &retval);
|
||||
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(jsThisObj), jsCallback, 2, valArr, &retval);
|
||||
}
|
||||
JSCallFunc::setTargetForNativeNode(node, (JSCallFunc *)this);
|
||||
|
||||
|
@ -119,7 +118,7 @@ public:
|
|||
private:
|
||||
jsval jsCallback;
|
||||
jsval jsThisObj;
|
||||
jsval *extraData;
|
||||
jsval extraData;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue