Spine Model

The SpineModel component is used to bring Spine skeletal animations to life in Defold.

Creating Spine model components

Select a game object to hold the new component:

Either create the component in-place (right click the game object and select Add Component ▸ Spine Model)

Or create it on file first (right click a location in the Assets browser, then select New... ▸ Spine Model from the context menu), then add the file to the game object by right clicking the game object and selecting Add Component File).

Spine model properties

Apart from the properties Id, Position and Rotation the following component specific properties exist:

Spine scene
Set this to the Spine scene file you created earlier.
Blend Mode
If you want a blend mode other than the default Alpha, change this property.
If you need to render the model with a custom material, change this property.
Default animation
Set this to the animation you want the model to start with.
If your model has skins, select the one you want it to start with.

You should now be able to view your Spine model in the editor:

Spine model in editor

Blend modes

The Blend Mode property defines how the component graphics should be blended with the graphics behind it. These are the available blend modes and how they are calculated:

Normal blending: src.a * src.rgb + (1 - src.a) * dst.rgb
Brighten the background with the color values of the corresponding pixels of the component: src.rgb + dst.rgb
Darken the background with values of the the corresponding pixels of the component: src.rgb * dst.rgb

Runtime manipulation

You can manipulate spine models in runtime through a number of different functions and properties (refer to the API docs for usage).

Runtime animation

Defold provides powerful support for controlling animation in runtime. Refer to the spine animation manual to learn more.

Changing properties

A spine model also has a number of different properties that can be manipulated using go.get() and go.set():

The current model animation (hash) (READ ONLY). You change animation using spine.play_anim() (see the spine animation manual).
The normalized animation cursor (number).
The spine model material (hash). You can change this using a material resource property and go.set(). Refer to the API reference for an example.
The animation playback rate (number).
The current skin on the component (hash).

Material constants

The default spine material has the following constants that can be changed using go.set() or go.animate() (refer to the Material manual for more details). Examples:

go.set("#spine", "tint", vmath.vector4(1,0,0,1))
go.animate("#spine", "tint", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(1,0,0,1), go.EASING_LINEAR, 2)
The color tint of the spine model (vector4). The vector4 is used to represent the tint with x, y, z, and w corresponding to the red, green, blue and alpha tint.

Project configuration

The game.project file has a few project settings related to spine models.

Did you spot an error or do you have a suggestion? Please let us know on GitHub!