Skip to content

Skeleton

Skeletal (cutout) animation from Spine or DragonBones exports: bones, meshes, skins, IK, events; crossfades; scripts can turn bones.

Type: SkeletonNode · Category: Animation & Effects · Also found as: skeleton, spine, dragonbones, bones, rig, cutout

Property Type Default Description
file string "" The skeleton: a Spine .json export or a DragonBones _ske.json (project-relative).
atlas string "" Its texture atlas; empty = next to it (name.atlas for Spine, name_tex.json for DragonBones).
armature string "" DragonBones: the armature to show (empty = the first).
animation string "" The animation played when the scene starts (and shown in the editor).
skin string "" The skin (attachment set); empty = the default skin.
loop boolean true Play the animation over and over.
autoplay boolean true Start the animation when the node becomes ready.
speed number 1 Playback speed (1 = as authored). Range 0 to 5.
mixTime number 0.15 Seconds to crossfade from one animation to the next. Range 0 to 2.
tint color #ffffffff Multiplies every slot’s colour.
showBones boolean false Draw the bones over the art (also in the game, for debugging).

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Connects a handler to one of this node’s events: animation_finished (A non-looping animation ended (Aseprite: a tag’s repeats are done)), skeleton_event (An event key of the skeleton’s animation fired (its name)); the tree events; custom ones.

self.node:connect("animation_finished", function(value, source) Log.info("animation_finished") end)
  • event SkeletonNodeEvent|string
  • handler fun(value: any, source: SkeletonNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("file")
  • path SkeletonNodeProperty|string

Returns any

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("file", "text")
  • path SkeletonNodeProperty|string
  • value any
  • y? number

SkeletonNode:skeleton_play(name, loop, mix)

Section titled “SkeletonNode:skeleton_play(name, loop, mix)”

Plays an animation (crossfading over mix seconds; default: the node’s Mix Time). False when the skeleton has no such animation.

skel:skeleton_play("run")
  • name string
  • loop? boolean Default true
  • mix? number Seconds

Returns boolean ok

Stops at the current frame.

skel:skeleton_stop()

An animation is playing.

if not skel:skeleton_is_playing() then skel:skeleton_play("idle") end

Returns boolean

Switches the skin (attachment set).

skel:skeleton_set_skin("armored")
  • name string

The animations’ names.

for _, a in ipairs(skel:skeleton_animations()) do print(a) end

Returns string[]

The skins’ names.

local skins = skel:skeleton_skins()

Returns string[]

The bones’ names.

local bones = skel:skeleton_bones()

Returns string[]

A bone’s position in the world (nil: no such bone).

local muzzle = skel:skeleton_bone_position("gun_tip")
  • name string

Returns Vec2?

A bone’s rotation in the world (degrees).

local angle = skel:skeleton_bone_rotation("arm")
  • name string

Returns number?

SkeletonNode:skeleton_set_bone_rotation(name, degrees)

Section titled “SkeletonNode:skeleton_set_bone_rotation(name, degrees)”

Overrides a bone’s local rotation (degrees) over the animation; nil gives it back to the animation.

skel:skeleton_set_bone_rotation("arm", aim_angle)
  • name string
  • degrees? number

Returns boolean ok

An animation’s length in seconds (default: the current one).

local t = skel:skeleton_duration("attack")
  • name? string

Returns number

{
"type": "SkeletonNode",
"name": "Skeleton",
"position": [
0,
0
],
"properties": {
"file": "",
"atlas": "",
"armature": ""
}
}