[ANSWERED] Invalid Native Object on XCode console but works on HTML5

[ANSWERED] Invalid Native Object on XCode console but works on HTML5
0.0 0


Hi all!

I’m still new on Cocos2d-x, and i’m not familiar with C++, so i’m veeery happy with the javascript bindings!

I’m using the 3.0alpha0pre version (2.1.4 for some reason don’t compile for android on my mac, 3.0 works like a charm and the 2.1.5 html5 version for html5 testing…

My problem is… i’m trying to do a simple animation… on Firefox it works flawlessly, but into the iPhone Simulator, it hangs… the console says:

@Cocos2d: JS: /Users/vinicius/Library/Application Support/iPhone Simulator/6.1/Applications/9938DA0A-D403-4CE3-B1EA-6E3C957E8D81/OneMoreTest.app/src/myApp.js:72:Error: Invalid Native Object@

I readed that this could be an autorelease issue of cpp, that differs from js on browser… so i tried to put .retain in everything… and the problem continues…

Here is the code)

var SplashLayer = cc.Layer.extend({
        cc.associateWithNative(this, cc.Layer);

        var splash = cc.Sprite.create(s_splashscreen);
        splash.setPosition(cc.p(splash.getContentSize().width/2, splash.getContentSize().height/2));

        // Attempt to use retain to make it work on Xcode
        var scene = new StartMenuScene();
        cc1 = cc.DelayTime.create(2);
        cc2 = cc.TintTo.create(0.5, 0, 0, 0);
        cc3 = cc.DelayTime.create(0.5);
        cc4 = cc.CallFunc.create(function(node) {
        }, this);
        ccs = cc.Sequence.create([cc1, cc2, cc3, cc4]);

        // Works on HTML5
            cc.TintTo.create(0.5, 0, 0, 0),
            cc.CallFunc.create(function(node) {
                cc.Director.getInstance().replaceScene(new StartMenuScene());
            }, this)



I believe the issue is you are sending an array into cc.Sequence.create instead of just multiple arguments cc.Sequence.create;

If this fixes your issue it’s because the browser runs pure javascript, but the c++ javascript bindings are much more strict.
If not, then I don’t see anything apparently wrong, but maybe if you upload the more of the code that may help.

From my limited experience so far:
Invalid Native Object usually means that the object calling the method, the method parameters, or the return value types are invalid. This is usually due to either an object having been released before the method is called on the object, or due to the wrong type of argument (e.g. array instead of multiple arguments).


Steve, if you were next to me right now, I would kiss you XDD

I just removed the brackets and voila! Everything works!

Thanks a lot!