ActionInterval.extend works for JS but not for JSB

ActionInterval.extend works for JS but not for JSB
0.0 0


With Reference to [[my previous Forum post|]]

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 [[]]

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# */{

    initWithNormalSprite:function (normalSprite, selectedSprite, disabledSprite, selector, target) {
        this._originalScale = 1;
        this.initWithCallback(selector, target);
        if (this._normalImage) {
        return true;

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

            var actionScale = cc.ScaleTo.create(0.1,this._originalScale*1.2);

    unselected:function () {

        if (this._isEnabled){
            var actionScale = cc.ScaleTo.create(0.1,this._originalScale);

    setEnabled:function (bEnabled) {
        if (this._isEnabled != bEnabled) {

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/ 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(){;