ActionInterval.extend works for JS but not for JSB

With Reference to [[my previous Forum post|http://www.cocos2d-x.org/forums/20/topics/35370]]

Im trying to override the +ActionInterval.Update()+ function on the JS side.

  1. When I run with JSB * then it only calls the +Action.Update+ super function and never calls myOverridde* function on my JS side.

  2. When I try to implement the Update() function in the CCActionInterval.cpp class then it also still never calls my Overriden function in JS…

What is going on here?

Should I Make all my Overriden Classes/Function available in the JSB first?

I’m having similar problems trying to extend from cc.MenuItemSprite item. On JS works fine, but on JSB doesn’t work.

Yes, I managed to Extend, first using the Native C++ code, then generate the JSB code, and then included that in my AppDelegate. As noted in my other article here [[http://www.cocos2d-x.org/forums/20/topics/35370?r=38493#message-38493]]

This allowed me access to my Class without needing to implement it in JS. The only place that I would need the JS Implementation is for the HTML5 version of the app.

the problem is that I’m extending from cocos2d-html5 version (and works), but I’m getting some troubles with the js-bindings.

Are you Building iOS or Android app?
What is the Error Message/Stack Trace?

let me show you the code.

JS.MenuItemSpriteScale = cc.MenuItemSprite.extend(/** @lends cc.MenuItemSprite# */{
    _originalScale:null,

    initWithNormalSprite:function (normalSprite, selectedSprite, disabledSprite, selector, target) {
        this._originalScale = 1;
        this.initWithCallback(selector, target);
        this.setNormalImage(normalSprite);
        this.setSelectedImage(selectedSprite);
        this.setDisabledImage(disabledSprite);
        if (this._normalImage) {
            this.setContentSize(this._normalImage.getContentSize());
        }
        return true;
    },

    selected:function () {
        this._super();
        if (this._isEnabled){
            var action = this.getActionByTag(JS.MenuItemSpriteScale_TAG);
            if (action) {
                this.stopAction(action);
            }else{
                this._originalScale = this.getScale();
            }

            var actionScale = cc.ScaleTo.create(0.1,this._originalScale*1.2);
            actionScale.setTag(JS.MenuItemSpriteScale_TAG);
            this.runAction(actionScale);
        }
    },

    unselected:function () {
        this._super();

        if (this._isEnabled){
            this.stopActionByTag(JS.MenuItemSpriteScale_TAG);
            var actionScale = cc.ScaleTo.create(0.1,this._originalScale);
            actionScale.setTag(JS.MenuItemSpriteScale_TAG);
            this.runAction(actionScale);
        }
    },

    setEnabled:function (bEnabled) {
        if (this._isEnabled != bEnabled) {
            this._super(bEnabled);
            this.setScale(this._originalScale);
        }
    }
});

JS.MenuItemSpriteScale.create = cc.MenuItemSprite.create;

JS.MenuItemSpriteScale.create = function (normalSprite, selectedSprite, three, four, five) {
    var len = arguments.length;
    var normalSprite = arguments[0], selectedSprite = arguments[1], disabledImage, target, callback;
    var ret = new JS.MenuItemSpriteScale();
    //when you send 4 arguments, five is undefined
    if (len == 5) {
        disabledImage = arguments[2];
        callback = arguments[3];
        target = arguments[4];
    } else if (len == 4 && typeof arguments[3] === "function") {
        disabledImage = arguments[2];
        callback = arguments[3];
    } else if (len == 4 && typeof arguments[2] === "function") {
        target = arguments[3];
        callback = arguments[2];
    } else if (len <= 2) {
        disabledImage = arguments[2];
    }
    ret.initWithNormalSprite(normalSprite, selectedSprite, disabledImage,  callback, target);
    return ret;
};

and this is the error.
As you can see, there is no method initWithCallback. I’m extending cc.menuitemsprite for having a menuitemsprite that scales when someone clicks on the button. But I’m having some troubles with this class.

Cocos2d: JS: /Users/jandujar/Library/Application Support/iPhone Simulator/7.0.3/Applications/5EDF4C1A-A60D-490D-BAAC-FBF1F12EB7F5/gtc.app/src/menuitemspritescale.js:8:TypeError: this.initWithCallback is not a function

I have a feeling you are missing a piece of code like this, I’m not the expert on this but give that a try:

    ctor: function(){
        cc.MenuItemSprite.prototype.ctor.call(this);
    },