Why my class couldn't extend from SpriteBatchNode or ClippingNode for js-binding?

As the title said, if i extended from SpriteBatchNode or ClippingNode, it worked very well on any browser. But for js-binding, it said “cc.ClippingNode.extend is not a function” or “cc.SpriteBatchNode.extend is not a function”. This happened also when i tried to compress the source code using the official ANT tool.

If it does not support this kind of extension, how about version 3.0?

Which version of JSB are you using?

Hi, @pandamicro
I used jsb 3.0 for that, maybe tried jsb 2.2 also, but when i compressed the source code with the ANT tool, that also happened!
Thanks!

As for JSB, all initWithXXX functions has been removed for Cocos2d-x v3.0, so it will break the ability to extend from cc.Sprite etc, the JSB v3.0 is not compatible with Cocos2d-html5.
Don’t worry, we are working on Cocos2d-html5 v3.0a which will be compatible with JSB v3.0

As for compression are you using simple mode or advanced mode?

Huabin

Thanks @pandamicro, as for compression, firstly i used advanced mode, then i got a error message but don’t know which line code caused the problem, then i switched to simple mode and found the error was threw on the line of “cc.SpriteBatchNode.extend”!

Hi, here is the screenshot of the error when compressing the source code!
Hope someone could help me! Or i give up this kind of extension!

Hi,

Seems that you haven’t compressed your own code while engine code has been compressed. So cc.ClippingNode must have been compressed to something like cc._mh (whatever what it really is), and you are still using cc.ClippingNode.

The solution is simple, add your own js file into build.xml for compressing. Then it should all go well.

Huabin

Hi @pandamicro:
Please check my build.xml, is there something wrong?
Thanks!

The build.xml file seems alright to me.

Please check your cocos2d.js, if you have activate the single engine file option like this: SingleEngineFile:"FruitsLink1.js"
And verify in browser which files have been loaded on your page. Then we can identify the problem

@pandamicro Thanks great, i double checked the build.xml, i found some cocos2d lib files were annotated including the CCClippingNode.js, i corrected all these lines and it worked. I have to say, the build.xml was copied from the official sample game, i didn’t know i should edit the xml for myself.
So, thanks for you patience.
BTW: Another “null” error came after i switched the compress mode from simple to advanced, because the code was obscured on this mode, so i haven’t know which line caused the problem. After all, on simple mode, it works perfectly! Let it be simple firstly!

You are welcome and I’m very happy that you succeeded.

For advanced mode of closure compiler, you can check out google’s documentation: https://developers.google.com/closure/compiler/docs/api-tutorial3

It will help you to avoid major problems which could be caused by advanced mode.

@pandamicro Thanks again!