Is there a way for calling function from a child to its parent if you have inherited using cocos model.
Example:
GreatestChildClassEver = cc.Sprite.extend({
ctor: ...
setPosition: function(pos) {
this._super().setPosition(pos); // this does not work but I want something equivalent.
}
});
I think there are difference between calling function of parent node and parent class as my experiences.
parent node
var parentNode = new cc.Node();
parentNode.parentFunction = function()
{
cc.log("parentFunction");
};
var childNode = new cc.Node();
parentNode.addChild(childNode);
childNode.getParent().parentFunction();
parent class
var childNode = new ExtendedNode();
childNode.setPosition(0, 0);
You should able to use parent class setPosition.
If you want to override the function, you may try this or use other function name.
Although, it might be an issue in JSB that cause extended class unable to inherit or use parent class function.
This is exactly what I wanted although I did not know about this issue. Thank very much, I think i’ll keep using different names for function inherited.