1
votes

I'm new with cocos2d. I'm using cocos2d-js 3.0 rc2, and want to develop a web game.

I have completed my code and it goes well with WebStorm in the debug mode. But when I release the codes to the real web server, there is a js error when run the game. (command: cocos2d compile -p web -m release)

I analysed the source(game.min.js) which is generate by the command above, and find the reason is that a field of an object is compressed by cocos, but the object is a external json data,which is the game data.

the json data is like the following: var stageData={rows:[{nodes:[{num:0},{num:0},{num:0}, ...;

the source before compile: this.rowNum = stageData.rows.length; this.colNum = stageData.rows[0].nodes.length;

the source after compile: this.Ph=stageData.rows.length;this.Di=stageData.rows[0].Jc.length;

"noes" is replaced to "Jc".

Can anyone tell me how to resolve this? Thanks!

1
please format your post - Kick Buttowski

1 Answers

0
votes

This is an issue with Google Closure Compiler (which Cocos2D-JS uses to minify the code for web apps). I'm currently suffering with this myself.

All I can do is point you to this article about the compiler's advanced compilation options, I'm currently reading that and seeing what works and what doesn't. I'll update if I find a definitive answer.