4
\$\begingroup\$

I have an existing Sprite Atlas with its data file in JSON format. How do I convert it for use with Cocos 2D and other frameworks ?

I tried poking around in Texture Packer which supports publishing to multiple formats. But I can't figure out how to convert from one format to another

EDIT : Is there any other software that is able to convert between different formats ?

\$\endgroup\$
2
\$\begingroup\$

Texture Packer won't convert it's exported data from one format to another. To export in different formats you need to have the Texture Packer (tps) file used to create your JSON atlas.

If you have the tps file, just select the exporter you need from the "Data Format" drop down list in the left-hand pane. The TP home page has a graphic that explains the process succinctly.

If you don't have the tps file you have two options:

  1. Write a script to parse the JSON format you have into the Cocos 2D format you need.
  2. Recreate the tps file so you can easily export whatever format you may need in the future. This assumes you have the source sprites that are packed into your atlas.
\$\endgroup\$
  • \$\begingroup\$ regarding of your first paragraph, note that he has the JSON atlas, he want to convert it to cocos2d format (aka. TP defautl export format) \$\endgroup\$ – Ali1S232 Aug 14 '13 at 17:53
  • \$\begingroup\$ @Ali.S Right, AFAIK TP does not convert JSON to Cocos2D, it exports tps to JSON or Cocos2D or any other supported format. \$\endgroup\$ – NoobsArePeople2 Aug 14 '13 at 18:02
  • \$\begingroup\$ Is there any other software that does do a conversion ? Seems like something that should already be out there \$\endgroup\$ – kira Aug 15 '13 at 1:57
  • 1
    \$\begingroup\$ @user34183 Yeah, it's called Texture Packer, you set it up and export to whatever format you want ;) If you can't do that it looks like the Cocos2D format is a plist (which is just an xml document) On OSX it looks like there is a util for converting JSON to plist though there probably isn't a straight one-to-one conversion from your JSON file to Cocos2D. Converting from JSON to plist should be an easy script to write. \$\endgroup\$ – NoobsArePeople2 Aug 15 '13 at 3:07
0
\$\begingroup\$

I just found this java tool:

https://github.com/thomas-villagers/gdxtococos2d

update: previous link doesn't work anymore, I found a fork:

https://github.com/midworld/gdxtococos2d

run on terminal:

java -jar gdxtococos2d-0.0.1-standalone.jar <inputfile>.atlas <outputfile>.plist 

...and done!

it worked for my game.

\$\endgroup\$
  • \$\begingroup\$ Hey @Andrey. The git repo can't be found. If the author has removed the repo, can you please put your code to your git and share with us? Thanks. I've .atlas format and I want to convert it to .json format \$\endgroup\$ – myDoggyWritesCode Dec 16 '16 at 15:54
  • 1
    \$\begingroup\$ Hi @user3241111, I found a fork and update the post, please let me know if it works for you. \$\endgroup\$ – Andrey Salas Dec 17 '16 at 16:28
  • \$\begingroup\$ Hey @Andrey. Thanks for the repo. I tried converting using it. It did work. But the plist seems to give lots of wrong values of <key>. I am checking again about the issue. Can you try it once, if it is working perfectly fine for you? I am using this atlas file . Thanks dropbox.com/s/5vo39pp3c6h7of5/spineboy.atlas?dl=0 \$\endgroup\$ – myDoggyWritesCode Dec 17 '16 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.