Cocos-2dx JS can't load scene from JSON file with version 3.10.0.0

324 views Asked by At

I'm using Cocos-2dx JS for a game project. The Cocos version I use is 3.10. To create the GUIs of my game, I used Cocos Studio and then I generate JSON file of said scene using Cocos Studio. However, the generated JSON file version is 3.10.0.0, and when I compile my project, it got the error "JSON is undefined". When I changed the version attribute of the JSON file to 2.1.0.0, the project run without a problem. Anyone has experienced same error can explain why this happens and how to fix it? Thank you very much.

1

There are 1 answers

0
Duy Nguyễn On

I found a simple solution that works well for me. All you need to do is go to the Cocos Studio project folder and open YourProjectName.cfg. Find two lines that look something like below.

<CreateFrameworkVersion Value="cocos2d-x-3.10.0.0" />
<CurrentFrameworkVersion Value="cocos2d-x-3.10.0.0" />

Modify the value of CreateFrameworkVersion and CurrentFrameworkVersion to "cocos2d-x-2.10". Then, save it. Now, whenever you publish the project, the JSON file version will be 2.10.

Remember you have to close your Cocos Studio project first.