Can't override all functions in JsBinding? CCNode setPosition override

Can't override all functions in JsBinding? CCNode setPosition override
0.0 0


I’m trying to create a class that extends CCNode and override all position methods, so it can works as a camera, and simplify the movement through the scene.
I have overridden all position methods: getPosition, setPosition, setPositionX… and that worked fine in html 5, but when I’m trying to use these methods in JavaScript binding, it appears as the setPosition method is no being override, it appears to be calling the CCNode implementation. It is possible that I can’t override this method using jsBingings? It’s possible it can’t be overridden due some performance issues? I’m searching for other methods can’t be overridden and I can’t find the explanation of that fact.
I keep looking, but some help would be appreciated.


How did you override the methods? Could you paste some codes?


I have it overriden just as a call to the prototype and leave a log.

setPosition:function (newPosOrxValue, yValue) {
cc.log(“setPositionOverride blank”);,newPosOrxValue,yValue);
getPosition:function () {
cc.log(“getPosition override”);

From the actual scene i make this calls:

var cameraPos = this.m_mainCamera.getPosition();
cc.log(“camera position1”cameraPos.x" “+cameraPos.y);
cameraPos = this.m_mainCamera.getPosition();
cc.log(”camera position2 “cameraPos.x” "+cameraPos.y);

When i see the log it appears as my setPosition method implementation is not beeing called.

Cocos2d: JS: getPosition override

Cocos2d: JS: camera position1 0 0

Cocos2d: JS: getPosition override

Cocos2d: JS: camera position2 1010

That only happens in jsBingings, in html works fine.


But it seems getPosition works.


I found out the reason.
It’s because we’re using JSPROP_READONLY for Node::setPosition.
You could simply fix this issue by searching

JS_DefineFunction(cx, jsb_Node_prototype, "setPosition", js_cocos2dx_CCNode_setPosition, 1, JSPROP_READONLY | JSPROP_PERMANENT);

And change it to

JS_DefineFunction(cx, jsb_Node_prototype, "setPosition", js_cocos2dx_CCNode_setPosition, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);


Thanks James, that solved my problem


This issue was created at . Thanks.