From 7e55ed4d9e820945dd1aa87d948e2127e7ecf589 Mon Sep 17 00:00:00 2001 From: Frank Watson Song Date: Fri, 27 Sep 2013 09:27:28 +0800 Subject: [PATCH 1/2] Add spine data support. --- src/utils/formatSpineData.as | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/utils/formatSpineData.as b/src/utils/formatSpineData.as index 34510d1..22f9982 100644 --- a/src/utils/formatSpineData.as +++ b/src/utils/formatSpineData.as @@ -52,6 +52,8 @@ const A_SCALE_X:String = "scaleX"; const A_SCALE_Y:String = "scaleY"; const A_WIDTH:String = "width"; const A_HEIGHT:String = "height"; +const A_INHERIT_SCALE:String = "inheritScale"; +const A_INHERIT_ROTATION:String = "inheritRotation"; const V_STEPPED:String = "stepped"; @@ -118,6 +120,40 @@ function formatBone(boneObject:Object):XML {ConstValues.A_SCALE_Y}={formatNumber(boneObject[A_SCALE_Y])} /> ; + + var inheritRatation:String = boneObject[A_INHERIT_ROTATION] as String; + switch (inheritRatation) + { + case "0": + case "false": + case "no": + boneXML.@[ConstValues.A_FIXED_ROTATION] = true; + break; + default: + boneXML.@[ConstValues.A_FIXED_ROTATION] = false; + break; + } + + var inheritScale:String = boneObject[A_INHERIT_SCALE] as String; + if (inheritScale) + { + switch (inheritScale) + { + case "1": + case "true": + case "yes": + boneXML.@[ConstValues.A_SCALE_MODE] = 0; + break; + default: + boneXML.@[ConstValues.A_SCALE_MODE] = 1; + break; + } + } + else + { + boneXML.@[ConstValues.A_SCALE_MODE] = 0; + } + var parent:String = boneObject[A_PARENT]; if(parent) { From 94a34997cdfbb2043707c75b0d3c665308e67c58 Mon Sep 17 00:00:00 2001 From: Frank Watson Song Date: Fri, 27 Sep 2013 14:44:27 +0800 Subject: [PATCH 2/2] Modify spine file loader, support slot and display object scale. --- src/utils/formatSpineData.as | 41 +++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/utils/formatSpineData.as b/src/utils/formatSpineData.as index 22f9982..981e1eb 100644 --- a/src/utils/formatSpineData.as +++ b/src/utils/formatSpineData.as @@ -33,6 +33,7 @@ const TRANSLATE:String = "translate"; const SCALE:String = "scale"; const COMBINE:String = "combine"; const ATTACHMENT:String = "attachment"; +const ADDITIVE:String = "additive"; const COLOR:String = "color"; const A_NAME:String = "name"; @@ -142,16 +143,16 @@ function formatBone(boneObject:Object):XML case "1": case "true": case "yes": - boneXML.@[ConstValues.A_SCALE_MODE] = 0; + boneXML.@[ConstValues.A_SCALE_MODE] = 2; break; default: - boneXML.@[ConstValues.A_SCALE_MODE] = 1; + boneXML.@[ConstValues.A_SCALE_MODE] = 0; break; } } else { - boneXML.@[ConstValues.A_SCALE_MODE] = 0; + boneXML.@[ConstValues.A_SCALE_MODE] = 2; } var parent:String = boneObject[A_PARENT]; @@ -172,6 +173,7 @@ function formatSkin(skinObject:Object, skinName:String, slotList:Array, textureA var parentName:String; var firstAttachment:String; + var blendMode:String; var zOrder:int; for(var slotName:String in skinObject) { @@ -183,24 +185,42 @@ function formatSkin(skinObject:Object, skinName:String, slotList:Array, textureA { parentName = slotObjectInList[A_BONE]; firstAttachment = slotObjectInList[ATTACHMENT]; + var additive:Object = slotObjectInList[ADDITIVE]; + if(additive && additive is Boolean) + { + var isAdditive:Boolean = additive as Boolean; + if(isAdditive) + { + blendMode = "add"; + } + else + { + blendMode = "normal"; + } + } + else + { + blendMode = "normal"; + } break; } zOrder ++; } //默认的display标记出来,以便放到displayList的首位 - skinXML.appendChild(formatSlot(skinObject[slotName], slotName, parentName, firstAttachment, zOrder, textureAtlasXML)); + skinXML.appendChild(formatSlot(skinObject[slotName], slotName, parentName, firstAttachment, blendMode, zOrder, textureAtlasXML)); } return skinXML; } -function formatSlot(slotObject:Object, slotName:String, slotParent:String, firstAttachment:String, zOrder:int, textureAtlasXML:XML):XML +function formatSlot(slotObject:Object, slotName:String, slotParent:String, firstAttachment:String, blendMode:String, zOrder:int, textureAtlasXML:XML):XML { var slotXML:XML = <{ConstValues.SLOT} {ConstValues.A_NAME}={slotName} {ConstValues.A_PARENT}={slotParent} {ConstValues.A_Z_ORDER}={zOrder} + {ConstValues.A_BLENDMODE}={blendMode} />; var displayXML:XML; @@ -240,6 +260,17 @@ function formatDisplay(displayObject:Object, displayName:String, textureAtlasXML scaleX = width / Number(subTextureXML.@[ConstValues.A_WIDTH]); scaleY = height / Number(subTextureXML.@[ConstValues.A_HEIGHT]); + var spineScaleX:String = displayObject[A_SCALE_X]; + if (spineScaleX) + { + scaleX *= Number(spineScaleX); + } + var spineScaleY:String = displayObject[A_SCALE_Y]; + if (spineScaleY) + { + scaleY *= Number(spineScaleY); + } + if(isNaN(scaleX)) { scaleX = 1;