Spine is a third party animation tool by Esoteric Software that allows you to create animations where movement of bones in a skeletal rig drives various parts of the animated object. It is particularly useful to animate characters and animals, but works very well for other types of objects, like ropes, vehicles or foliage.
Defold implements runtime evaluation and animation expressed in the Spine JSON format.
Defold supports most of Spine’s animation features, including inverse kinematics (IK).
Currently, Defold does not support animation keys that flip bones over the X or Y axis. Defold supports mesh animation but only with bones, meaning that you can’t animate single vertices. If you need to animate single vertices you can do that through a bone being 100% bound to that vertex only and animate the bone.
The Spine runtime implementation in Defold supports all Spine 2.x features. The runtime provides only limited additional support for Spine 3.x features. Make sure to use only Spine 2.x features to ensure compatibility with the Defold runtime!
The Spine JSON data format that Defold supports can be created by Esoteric Software’s Spine software. In addition, Dragon Bones has the ability to export Spine JSON data files.
Spine is available from http://esotericsoftware.com
Dragon Bones is available from http://dragonbones.com
Dragon Bones should typically be able to export to Spine JSON data files without any problems. If your Dragon Bones exported data file isn’t rendered properly in Defold we recommend that you use the official Spine Skeleton Viewer to first verify that the data can be correctly parsed. If there is a problem with the exported data the Spine Skeleton Viewer can pinpoint problems in the JSON data file, for instance missing or incorrect fields.
When you have a model and animations that you have created in Spine, the process of importing them into Defold is straightforward:
If you work in Dragon Bones, simply select Spine as your output data type. Also select Images as image type. This will export a .json file and all necessary images into a folder. Then add those to Defold as described above.
When you have the animation data and image files imported and set up in Defold, you need to create a Spine scene resource file:
When you have all data imported and your Spine scene resource file ready, you can create SpineModel components. See SpineModel documentation for details.
You can also use Spine animations in GUI scenes. See the GUI spine documentation for details.
Defold gives you powerful runtime control of how animations should play through a Lua interface. See the Animation documentation for details.
The animation data references the images used for the bones by name with the file suffix stripped off. You add images to your Spine project in the Spine software and they are listed in the hierarchy under Images:
This example shows files laid out in a flat structure. It is, however, possible to organize the files in subfolders and the file references will reflect that. For instance, a file head_parts/eyes.png on disk will be referenced as head_parts/eyes when you use it in a slot. This is also the name used in the exported JSON file so when creating the Defold image atlas, all names must match an atlas animation.
If you select Add Images Defold will automatically create animation groups with the same name as the added files, but with the file suffix stripped off. So, after having added the file eyes.png its animation group can be referenced by the name “eyes”. This works with file names only, not paths.
So what do you do if your animation references “head_parts/eyes”? The easiest way to accomplish a match is to add an animation group (right click the root node in the Atlas Outline view and select Add Animation Group). You can then name that group “head_parts/eyes” (it’s just a name, not a path and
/ characters are legal) and then add the file “eyes.png” to the group.
Moving on to animate your Spine model, please read the Animation documentation.
Did you spot an error or do you have a suggestion? Please let us know on GitHub!GITHUB