Spine Runtime With Cocos2D - RareSloth Games
spine runtime with cocos2d

Spine Runtime With Cocos2D

If you couldn’t tell by now, we are fans of Spine and cocos2d. The fact that the creators of Spine produced a runtime to be used with cocos2d (among other game libraries) makes us even happier. The runtime for cocos2d-iphone is pretty much a library of c headers and implementation files, along with a single objective-c class: CCSkeleton.

The CCSkeleton class has some convenience methods (actually, was just recently removed), but its main purpose is to house the gl drawing code to get the pieces of the spine skeleton drawn on the screen. Using the convenience methods (or c counterparts), we can set the current animation of the spine in one line of code:

[skeleton setAnimation:@”run” loop:YES];
AnimationState_setAnimationByName (skeleton->state, “run”, true);

Goodbye exporting frames, goodbye CCSpriteBatchNode. Hello easy animation switching, hello smooth looking games. And when I say smooth, you can literally change the pace of one animation mixing into the next:

[skeleton setMix:@”run” to:@”idle” duration:0.3];
AnimationStateData_setMixByName (skeleton->state->data, “run”, “idle”, 0.3);

It’s convenient and costs little time upfront to integrate and will give you a huge time savings in the future when it’s time to make changes to animations. Just what we needed for our agile process. Spine is still relatively new so I don’t think there would be much demand for a tutorial on the integration process right now, but contact us if you would like more information!

Comments are closed.