Cocos2dx skeleton animation Armature source code analysis (2), cocos2dxarmature
The previous article introduces the built-in skeleton animation of cocos2dx in general. This article introduces the meaning of each field of the exported configuration data (also explains the meaning of each field of xml data exported by DragonBone ).
Skeleton Node
<skeleton name="Dragon" frameRate="24" version="2.2">
Name: the name of the flash file.
FrameRate: Specifies the Frame Rate of the flash.
Version: the version number of dragonbones.
Armatures Node
The armatures node intercepts some data in armatures.
<armatures> <armature name="Dragon"> <b name="tail" parent="body" x="." y="-." kX="" kY="" cX="" cY="" pX="." pY="." z=""> <d name="parts-tail" pX="" pY="-."/> </b> <b name = "LegR" ... /> <b/> …… <b/> </armature> </armatures>
<B/> A node is a skeleton (B is short for bone). <armature/> A node contains multiple <B/> and is the overall skeleton of an animation. As shown in the following two figures, the relationship between the entire layer and the skeleton is an armature node, and each layer in the red box is a B node.
<Armatures> Why does a node have multiple armature nodes? Because a flash can have multiple bone animations, each of which corresponds to an armature. For example, after the flash export, armatures will contain multiple armature. A component with a frame label will be treated as a Skeleton.
<Armatures name = "Dragon"> the name attribute is the name () of the component in the library and also the name of Skeleton.
Node B (child node of the armature node)
<b name="tail" parent="body" x="45.9" y="-70.8" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.35" z="10">
Skeleton information, based on the first frame of information.
Name: the name of the skeleton, that is, the name of the layer in TimeLine ,.
Parent: parent node of the skeleton ,.
X, y: coordinates of the element rotation anchor point relative to the origin of the parent node. For details, see. The downward direction of y is positive.
KX, kY: Indicates skewX and SkewY. Generally, two equal values indicate the Rotate size.
CX, cY: Indicates scaleX and scaleY, indicating the scaling size.
PX, pY: the coordinates of the rotation anchor point relative to the component origin. The rotation is 30 degrees.
Z: hierarchy. The bottom layer is layer 0, which increases progressively.
D Node
Displaying nodes in the skeleton can be understood as skin. When a layer uses components in several libraries, there are several <d> nodes.
<d name="parts-tail" pX="0" pY="-63.8"/>
Name: displays the object name. It is the concatenation of the path and component name in the library.
PX, pY: displays the object's displacement from the origin.
Animations Node
<Animations/> nodes represent time-varying bones.
<animations> <animation name="Dragon"> <mov name="stand" dr="" to="" drTW="" lp="" twE=""> <b name="tail" sc="" dl=""> <f x="." y="-." cocosd_x="." cocosd_y="-." kX="" kY="" cX="" cY="" pX="." pY="." z="" dI="" dr=""/> <f x="." y="-." cocosd_x="." cocosd_y="-." kX="." kY="." cX="" cY="" pX="." pY="." z="" dI="" dr=""/> <f x="." y="-." cocosd_x="." cocosd_y="-." kX="" kY="" cX="" cY="" pX="." pY="." z="" dI="" dr=""/> </b> </mov> <mov name="walk" dr="" to="" drTW="" lp="" twE=""> </mov> <mov name="jump" dr="" to="" drTW="" lp="" twE="NaN"> </mov> <mov name="fall" dr="" to="" drTW="" lp="" twE="NaN"> </mov> </animation> </animations>
Why does <animations/> have multiple <animation/>? The cause is the same as that of <armatures/> multiple <armature/> (see the preceding Section). The animation and armature correspond to the name attribute one by one.
Mov Node
The mov node actually corresponds to an animation in the program. A frame label on the TimeLine generates an mov, so there are multiple mov values in one <animation/>.
<mov name="stand" dr="7" to="6" drTW="30" lp="1" twE="0">
Name: Specifies the frame tag name.
Dr: the number of frames in a duration and mov duration. We can see that stand lasts for 7 frames.
To: I really don't know what it is.
DrTW: represents duratio_tween, the duration of animation running, 1/24x7 = 0.29 s. Setting TotalTime on the dragonbones panel affects this value.
Lp: Indicates loop and whether loop playback is enabled.
TwE: I really don't know what it is.
Node B (child node of mov node)
The skeleton status. mov has all the bone B nodes.
<b name="tail" sc="1" dl="0">
Name: Bone name
SC: represents movement_scale. I don't know what it is. Adjust the total number of frames. The dragonBones Panel can be adjusted.
Dl: Indicates movement_delay. I don't know what it is. PlayDelay settings in the dragonBones panel should be related to them.
F Node
<f x="45.9" y="-70.8" cocos2d_x="124.1" cocos2d_y="-229.25" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.35" z="10" dI="0" dr="2"/>
Key Frame information. The stand animation has three key frames, so there are three f nodes. The attributes of x, y, kX, kY, cX, cY, pX, pY, and z are the same as those of the child nodes of the armature node, cocos2d_x and cocos2d_y do not know how to come.
DI: The graph displayed by display_index (<d> </d> in <B> </armature> ).
Dr: Number of duration frames.
TextureAtlas Node
You can select the dragonbone export mode. If you select to export a large image, the TextureAtlas node represents the information about the small graph in the large graph and can be understood as the plist file generated by TexturePacker, such
<TextureAtlas name="Dragon" width="" height=""> <SubTexture/> <SubTexture name="parts-tail" width="" height="" cocosd_pX="" cocosd_pY="-." x="" y=""/> <SubTexture/> <SubTexture/> <SubTexture/> </TextureAtlas>
The SubTexture node is the small Graph Information, the width and height are the length and width, and the x and y are the coordinates in the large graph. Cocos2dpX and cocos2dpY are still unknown.
The above content is the cocos2dx bone animation Armature source code analysis shared by the Helper House (II). It will be closer in the future. Please stay tuned to this site.