Skip to content

SkeletonObject Guide

Peter Robinson edited this page Aug 10, 2021 · 3 revisions

Introduction

All scene objects are known engine types that allow instances to be created at runtime. The "SkeletonObject" is a sprite-like object which allows the use of skeletal animation. As usual, it is derived from "SceneObject", which means it includes all the fields from that type as well as adding fields specific to itself.

A SkeletonObject uses the data from a SkeletonAsset, which in turn comes from a special skeletal animation program. Skeletal animation is a technique in which a character is represented in two parts: a surface representation used to draw the character (often called a skin) and a hierarchical set of interconnected bones (i.e. the skeleton) used to animate the skin.

Please note that SkeletonAssets are currently powered by Spine which requires a valid Spine license. Because of this, Spine support has been moved to a separate branch named masterspine. You will have to use that code to use Spine.

TorqueScript Bindings

Exposed Fields

The SkeletonObject type exposes the following fields in addition to those it inherits. Shown are the equivalent methods available that perform the same action in setting and getting the respective field:

  • Asset
  • setSkeletonAsset(string)
  • getSkeletonAsset()
  • AnimationName
  • setAnimationName(string)
  • getAnimationName()
  • Skin
  • setSkin(string)
  • getSkin()
  • RootBoneScale
  • setRootBoneScale(float)
  • getRootBoneScale()
  • RootBoneOffset
  • setRootBoneOffset(float)
  • getRootBoneOffset()
  • AnimationCycle
  • setAnimationCycle(bool)
  • getAnimationCycle()
  • FlipX
  • setFlipX(bool)
  • getFlipX()
  • FlipY
  • setFlipY(bool)
  • getFlipY()

The following is a complete description of each of these fields.

Asset (float)

Sets the SkeletonAsset to be used.

%object = new Skeleton();
%object.Asset = "SpineToy:Goblins";

AnimationName (float)

Sets the name of the animation to use.

Skin (float)

Sets the skin to display over the skeleton.

RootBoneScale (enum)

Sets the skeleton's root bone scale factor.

RootBoneOffset (bool)

Sets the skeleton's root bone offset in X and Y.

AnimationCycle (bool)

Sets whether the animation loops.

FlipX (bool)

Sets whether or not the texture is flipped horizontally.

FlipY (bool)

Sets wether or not the texture is flipped vertically.

TAML Format

Using TorqueScript and the exposed fields or methods described in the previous section, you can programmatically create and configure a SkeletonObject. You can then export this type to a TAML file or even create a TAML file manually and read it into your game at an appropriate time.

Here is an example SkeletonObject TAML file in XML format:

The same example in JSON format:

Additional API

The following methods are available to further configure and control a SkeletonObject.

getAnimationDuration ()

Gets the duration of the current animation in seconds.

setMix ()

Mixes the current animation with another.

Clone this wiki locally