Spine is a great software to design 2D animations for games, using modern techniques (bones, skins, meshes etc.). Animations done this way are lightweight: their loading and rendering is very efficient, even on mobile devices like Android or iOS. But they are also very flexible:
they look smooth regardless of the playback speed,
you can reuse the same animations by changing skins,
you can change attachments during animation,
and more (see Spine website for exhaustive list :).
You can use view3dscene to open Spine animations.
You can also add Spine animations using the editor, just add a
TCastleScene and set the scene
URL to point to the JSON file.
Just open a project exported from Spine (as a JSON file) using view3dscene File->Open .
To run a named animation, use Animations panel in view3dscene.
See our engine documentation for an overview how to use the engine.
When you run our editor, create a "New Project" and use template "2D Game". This shows a viewport with mutliple Spine scenes. A Spine scene is just a
TCastleScene instance and you add it to
TCastleViewport to make it visible, animated etc.
To play a Spine animation,
See viewport and scenes for more information about using viewports and scenes — there’s nothing special about scene using Spine model.
Basically, just create Spine models/animations as usual, and export them to JSON. Often it is comfortable to test your animations first in view3dscene before trying them out in your game.
It is advised (although not required) to create an atlas when you export to JSON, as rendering with atlas will be more efficient. Atlas options:
Make sure to select "Bleed" at atlas creation options (it is necessary to avoid visible seams during rendering).
It is simpler to use "Atlas Per Skeleton", although we also support "Single Atlas For All Skeletons". The latter is more efficient when multiple skeletons share the images, but requires loading by a special URL like
my_animation.json#atlas:my_atlas_name (see below).
You can choose a skin at loading, by loading a filename like
my_animation.json#skin:my_skin_name instead of
By default we use the first (non-default) skin.
If you don’t know the list of possible skins: you can see them in Spine, or in our log.
For backward compatibility, instead of
my_animation.json#skin:my_skin_name we also support
my_animation.json#my_skin_name. But the latter form is deprecated.
We fully support all Spine texture atlas options.
This includes handling multiple atlas pages, stripping whitespace, rotating… so you can pack your atlases really tight.
We also support "single atlas for multiple skeletons" feature of Spine. You can use it when exporting (it can be beneficial, may allow to reuse texture space better). To do this, specify atlas name explicitly, like this:
my_animation.json#atlas:my_atlas_name . This will read atlas from file
my_atlas_name.atlas in the same directory as
To specify both skin, and atlas name, separate them by a comma, like this:
You can also work without the atlas (we expect images then to be inside
Support for all Spine versions, JSONs exported by Spine 3.x and 4.x are tested.
Of course, complete rendering of skeleton with attachments, and complete playback of normal bone animations (hierarchy of translations, rotations, scaling). All animations are imported from Spine, and can be selected by
Animation of slot timeline attachment, this allows to change the attachment during animation, e.g. to make something appear/disappear or for frame-by-frame animations.
Animation of slot color and transparency.
Animating slot draw order (draw order timeline).
Bezier curves for animating parameters.
Support for "mesh" attachment.
Partial support for "skinnedmesh" attachment. The skinnedmesh in setup pose is affected by bones correctly, and during animation it moves as a whole (is affected by parent bone transformation). Missing is the ability to recalculate vertexes affected by bones during animation (that is, to deform skinnedmesh during animation).
Spine "paths" are supported, to use as custom paths for any purpose in the game. Internally they are converted to
NurbsCurve X3D nodes, fully supported by the engine — you can render them, or query them for any purpose. They are invisible by default (
Shape.render = false), since that is the intention of Spine paths, but you can make them visible easily if needed. From view3dscene, use "Edit->Reveal All Hidden Shapes" to show them.
Our implementation of Spine converts the Spine project under the hood into an X3D node graph. This means that Spine animation is a full 3D model, and uses stuff like X3D interpolators for animation. This also means that you can use all existing X3D rendering/processing tools to extend the Spine animation (for example, you can use sensors, texture settings, screen effects, you can cast shadows!, you can use shaders etc.).
Note that you could also create an X3D file with your 2D world, where you insert multiple Spine animations with X3D
Inline node. This allows to combine multiple 2D and 3D models already at data level.
Some more exotic Spine animation features are not implemented (yet!). If you would like to see support for them please submit an issue or ask on Castle Game Engine forum. Or submit a pull request :). Many of the features below are a matter of adding some reading and conversion to X3DLoadInternalSpine unit.
Attachment type "regionsequence" (should be easy, but needs test models; in principle, this should be exactly how you can use things like "xxx@counter(4).png" in X3D MovieTexture with our engine, see https://castle-engine.io/x3d_extensions.php#section_ext_movie_from_image_sequence ).
Attachment type "boundingbox" (easy to do, convert to X3D TransformSensor; will need special code to actually use it for something).
Events and Event Timeline (easy to do; note that events don’t do anything by themselves, they just allow animator to "name" some events on the timeline; we would convert them to some sensor that can be watched (using X3D ROUTE) by user code).
IK (Inverse Kinematics). Difficulty unknown, this is a new Spine feature.
We do not support paths for "path constraints" or animations.