cocos2d-iphone runtime, export format change
April 4th, 2013
Recently it became time to tackle the cocos2d-iphone runtime. No one likes mixing C++ with Objective-C and they are right, it’s nasty business. Ultimately we decided to write a generic C runtime from scratch. This allows us to service C, C++, and Objective-C game toolkits with a single codebase. It is also very portable and can easily be wrapped to support other languages, such as Python.
We are happy to announce that the cocos2d-iphone runtime is ready for use! It is based on the generic C runtime (spine-c), but provides an Objective-C API to integrate better with your cocos2d code. Using it looks like this.
The other news we have is that we decided to make an organizational change to the Spine export format. Previously a skeleton was exported as a skeleton file and a number of animation files. This has changed to just a single file containing both the skeleton and all the animations for that skeleton. This makes loading skeletons faster, especially on mobile where SD card access is slow. A few hundred animations could take a multiple seconds to load if they were in separate files. Also, since this change stores animations centrally on the SkeletonData, runtime APIs are improved by allowing animation look up by name.
For those worried about loading all animations at once, don’t fret. It really is not much data, even with many hundreds of animations. In the highly unlikely case where someone needs to load a subset of the animation data, it would be trivial to modify the JSON loader for the runtime you are using.
The documentation and official runtimes have all been updated to handle the new format. We know there are a number of projects that have code using the old format. We are sorry if you have to change your code! The changes should be easy though. The data itself was not changed, only where it is located, so all your existing parsing code can be reused. We don’t change the format lightly, but decided there are enough benefits in this case to warrant the change.