-
Notifications
You must be signed in to change notification settings - Fork 1.6k
SkeletonObject Guide
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.
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.
Sets the SkeletonAsset to be used.
%object = new Skeleton();
%object.Asset = "SpineToy:Goblins";
Sets the name of the animation to use.
Sets the skin to display over the skeleton.
Sets the skeleton's root bone scale factor.
Sets the skeleton's root bone offset in X and Y.
Sets whether the animation loops.
Sets whether or not the texture is flipped horizontally.
Sets wether or not the texture is flipped vertically.
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:
The following methods are available to further configure and control a SkeletonObject.
Gets the duration of the current animation in seconds.
Mixes the current animation with another.