For anybody who would like to hide the js file but has no idea like me.
There are 2 options under tools section
- closure-compiler (doesn’t work for me)
- cocos2d-compiler
i use option 2 and that finally work for me.
i have to say it is a painful process to learn how to do it for me.
here are the steps.
copy compiler_config_sample.json from tools/cocos2d-console/console/bin/
edit and list all your js in the list. (this help you compress all js file into 1 jsc files)
run
tools/cocos2d-console/console/cocos2d.py jscompile
to convert all your js file to jsc file
there are 2 options here, it can pack all your js file to jsc file, 10 in 10 out.
or it can pack all js file into 1 single file (doesn’t work for me for unknown reason)
if the above doesn’t work for you ,here is one extra steps nobody ever mentioned before (at least i can’t dig anything up in this forum)
in theory this step can be ignore but it just work for me.
-
modify the AppDelegate.cpp ScriptingCore::getInstance()->runScript(“cocos2d-jsb.js”); to ScriptingCore::getInstance()->runScript(“cocos2d-jsb.jsc”);
-
copy scripting/javascript/bindings/js/ folder and paste in your projects/src folder (so they can be convert to jsc as well)
-
modify js/jsb.js and change all require from js to jsc
-
modify your main js (cocos2d-jsb.js or main.js) and change require jsb.js to jsb.jsc and all your file extension from js to jsc
-
run jscompile again to convert all js file to jsc file.
-
in your proj.android/assets/ folder delete all jsb_xxx.js and move all your usb_xxx.jsc from proj.android/assets/js to proj.android/assets/
cocos 2d 2.2.x
original message above
Hi All,
First of all i am not 100% sure i should post this here, but since i am using jsb, i put the post here.
Recently i start testing pack my html5 code to android apk using jsb.
the result is all good so far, the apk create successfully and it can install and run on a real device for testing.
as a pkg file, i can simply unpack the whole thing by winrar.
and i can see all the asset file in the asset folder and ALL THE JS CODE!
are there anyway to hide those js code?
i think it is way too easy for someone to clone the whole game code without any technical skill.
thanks for any input in advance.