In the previous post we told you how to export a key frame animation. But when you want to create a hero with many animations, maybe the frame numbers are hundreds, even thousands. If you export it as a key frame animation, the texture size will be very very big. For any reason, we should export it as a skeleton animation. Take the bearAnim.fla for example in the previous post, we divide the bear head into three parts: face, ear0 and ear1. Each layer play a animation of one part. Set the linkage class of the bearHeadAnim to “mc.bearHeadAnim”. “mc” is the name of MovieClip for short, it tells the Flax tool it is a skeleton animation and parse it’s children information instead of drawing every frame. In one word, if you want to export a skeleton animation, then set its linkage class to mc.xxxxx, xxxxx is the name you can access in game!
The most important thing is that you must set the linkage class for every part of the skeleton animation. Here we name it as face, ear0 and ear1.
When we export this animation with Flax, we get this texture.
When export key frame animation, the texture has 49 sub textures. But now you can only see 3 sub textures. Why? It’s skeleton animation, we export only every part of the animation and parse its children transform information into the json file and then playback it according to the transform information on every frame. How to use it in the game? It is just same as the key frame animation. But it has another function to replace some child to another . For example, in the “face” layer of the bearHeadAnim MovieClip, if all the instances in this layer are named into “face”, and there is another MovieClip with linkage class of “face1”. Then we can do this:
var bearAnim = lg.assetsManager.createDisplay(“bearAnim.json”, “bearHeadAnim”);
this.addChild(bearAnim);
bearAnim.play();
bearAnim.replaceChild(“face”, “face1”);
With the last line of code, we can see the bear’s face is not “face” any more, it’s “face1” now. This is the magic of skeleton animation. With this function, we can do some complicated things such as change clothes or weapon for a hero with only one suit of animation!
You must be logged in to post a comment.