3

I am currently using sprite animation in my cocos2dx game using plist.
The coding language I'm using is c++.
Now, I want to switch over to the flash animations because of reasons below:

  1. They take lower memory
  2. Easy to handle and use
  3. Better Quality

Can anyone tell me how to do it. I just want to know where to start from.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
Jain
  • 854
  • 5
  • 15

4 Answers4

3

It is tempting to use the advantages of Flash mature animation tools, but unfortunately there is no "out of the box" solution.

There are however ways to get the job done:

1) Use tools like CreateJS to export the animation as a JS file. Then make a script that will parse the data to a *.plist file with links to exported images, their position etc. Later use a tweener to animate the graphics. You will also need to manually draw the vector shapes and save them as .PNG files as CreateJS doesn't export them as PNGs. But it's easy since CreateJS uses the save API as Flash and you can get all the shapes accurately.

The downsides are:

  • CreateJS has no support for complex gradients

  • Parsing JS to PLIST is a pain, it took me a whole day to write it. Be ready to use a lot of RegExp

NOTE: if you'll use CreateJS toolkit in the settings uncheck the Compact shapes option, it will make vector data to appear readable.

2) Make a tool that will read the SWF with animation and save each animation as a PNG sequence or a sprite sheet (sprite sheets work better with COCOS2dx).

The downsides are:

  • File size will grow comparing to SWF because you'll have every frame of every animation as raster (unless you have vectors so complex that they take more space than raster).
  • You'll have to have all the animation present on the stage, because it's problematic to target MovieClips from the library, or impossible if they're not exported for AS.

3) Dive into JS:FL and make your own tool that will export all the graphics in a format usable to you. There are no downsides, but I find it harder to do.

4) If you don't have multi-level animations with MovieClips inside MovieClips you can just right-click on an animation and export it as a sheet/sequence, it's very fast to do, but you'll spend a lot of time editing FLA file to meet the requirements if you have multiple levels (you'll need to convert parent MC to a graphics so it would play on a single timeline).

You may want to export the animation in alternative ways rather than sprite sheet or sequence, like a bone animation where you save every part of a more complex animation and a list of tweens/animation points. I wrote a about it here: Using SWF animation in Haxe/OpenFL applications It's not about COCOS, but it will work with any technology universally of platform.

As you see it's not all bad news, but you'll have to do some coding for that as there are no public tools that do that. I had to make all of the tools listed above and I can recommend you to stick with the 1st choice.

Community
  • 1
  • 1
Creative Magic
  • 3,143
  • 3
  • 28
  • 47
1

The best solution is GAFConverter. You can find GAF Animation Player on Cocos 2dx website. It helps you to convert your animations into one format and add them then to your project easily.

Bill
  • 11
  • 1
0

You can import Flash animations into CocoStudio tool and further you can create or export animations for Cocos2d-x projects.

Check out Cocos2d-x-2.2 version. There are many examples included in TestCpp project in extensions category.

Check out CocoStudio tool http://www.cocos2d-x.org/download

Vikas Patidar
  • 42,865
  • 22
  • 93
  • 106
0

I wrote my own lightweight solution for this. It's in Objective C / Cocos2d, but you may be able to convert it - it's only a few classes.

A simple library to export and animate Flash symbols in iOS / cocos2d, with included example.

Workflow:

  • Create your animations in Flash as MovieClips with animated layers containing Graphic symbols.
  • Export animations as JSON + frame PNGs using included JSFL script.
  • Convert PNGs into sprite sheets (use your own tools, I use - http://www.codeandweb.com/texturepacker)
  • Include animation JSON file(s) and sprite sheets in app bundle.
  • Load textures, run complex multilayer animations on sprites using simple commands.

Check it out on github:

This is my first github submission and I'm curious how useful people find it, so let me know.

Kirill E.
  • 338
  • 2
  • 9