JSB Issues

JSB Issues
0.0 0



I`m new in develop game with Cocos2D.
I`m develop one game with Cocos2d HTML5, at browser the game run very well, but when I`m try to run at IPhone many errors occur.
I`m lost a lot of time tried to find this erros, some erros I could find but other no.

I have this mysterious error
jsb: ERROR in JSB_jsval_to_NSObject: Error obtaining proxy
jsb: ERROR in JSB_jsval_to_NSObject: Error obtaining proxy
jsb: ERROR in JSB_CCNode_addChild_z_tag_: Error processing arguments*

This happens when I try add a second child at my layer

this._mainLayer.addChild( this._lastBg, 0, 0 );

Anyone knows what this error means ?




Hi Brunno,
did you got it? Actually i got the same error. I just create a sprite by

and i got the error. But i can call setAnchorPoint() and setPosition(). That works.
thank you,


Hi, Brunnot

Can you try to use this._mainLayer.addChild( this._lastBg, 1, 1 ); and tell if this get through the problem?
I’m not sure if this is the reason



Hi Huabin,
i changed it to provide 3 parameters but i still get the error.
If i change the sprite creation to var _bgSprite = new cc.Sprite() then i already get an error in the next call setAnchorPoint()
jsb: ERROR in JSB_CCNode_setAnchorPoint_: Invalid Proxy object
if i try to set the anchor point.
I do all this stuff in my own init method (called initWithScene) in a class derived from cc.Sprite. Within methods of cc.Layer i can create sprites and add them. Maybe this is the reason? But normalliy it should work to add a sprite to a sprite. Right?
thanks in advance,


As i stated above, actually i do not add the sprite to an object of cc.Sprite but to an object of my own class levelHud which is derived from my own class hud which is derived from cc.Layer. Could this be the reason that there are no ‘proxy objects’ for levelHud and hud?


Got it!
I need to call explicitely this.init() within my ctor. Then it works.
Is there any resource that explains when to call init() myself? If i use cocos2d-html5 it will be called within all the create-Methods.
Does that mean, i need to call it myself if i create objects via ctor?


Oh, great to hear that you have found the problem !

For your question about init, you should always call init function for your sub class of any cc.Node and its descendants. In most case, if you don’t call init function, it will trigger some problem soon or later. Because the init function will initialize some important properties.
If you extend the init function, you should make a super call in it like this:

init: function() {

Pay attention which init function you need also, for example, in cc.Sprite, you have: initWithFile, initWithTexture, initWithSpriteFrame, that depends on your implementation.



Hi Huabin,
i played around a little bit and switched to v3.0beta2. I saw (and another member told me), some init-Methods where removed like initWithSpriteFrame. Why that? So the code works with cocos2d-html5 but no longer with jsb on ios.
Here is the other Thread: http://cocos2d-x.org/forums/20/topics/45496


Hi, @roelfsche

The current Cocos2d-html5 is not compatible with JSB in Cocos2d-x v3.0, because the current version of Cocos2d-html5 is still 2.2.2. The alpha version of 3.0 will be soon available



Hi Huabin,
thank you for that information. So there is no possibility to release my game (developed under cococs-html5 v2.2.2) on ios because i use CCControlButtonwhich is not supported by jsb v2.2.2.
What is the best replacement for CCControlButton? CCMenuItemSprite?
thank you,