For example I have a character with many weapon, and each weapon have two part: left-hand and right-hand.
I create multi project, the character without weapon is one project, and each weapon has a project.
The character has two specify bone which named "left hand" and "right hand"
In each weapon, under the root bone, have two bone named "left hand weapon" and "right hand weapon". The weapon may have it's own animations, need to play separately. For instance a hunter hold a bow, when he play attack animation, the bow need play at the same time.
I want to load the weapon project, and attach the left-hand and right-hand bone under the character project, just like many 3D game skeleton system do.
I look through the API document but no good idea. Is there any way to achieve that?
And I want to request whether to add a feature, that user can load an external spine project into this project, attach it under a slot as an attachment.
It will useful if the character need to change cloth, some cloth has many frame animation to present the wind blow the cloth, but some cloth like armor is just an image. Current the spine support frame animation but in embed into the animation timeline. If I have a walk animation, I need build the frame animation inside the walk animation, so I need the create the animation for each type of cloth.
May be there have some other way to solve this problem elegant, for I am a newbie of spine, I am not quite sure whether I am right.
I am add a SkeletonAttachment as a subclass of Attachment in actionscript code:
package spine.starling
{
import spine.attachments.Attachment;
import spine.starling.SkeletonAnimation;
public class SkeletonAttachment extends Attachment
{
private var _skeletion:SkeletonAnimation;
public function SkeletonAttachment(name:String, skeletion:SkeletonAnimation)
{
super(name);
_skeletion = skeletion;
}
public function set skeletion(skeletion:SkeletonAnimation):void
{
_skeletion = skeletion;
}
public function get skeletion():SkeletonAnimation
{
return _skeletion;
}
}
}
And I modify the SkeletonSprite render function:
override public function render (support:RenderSupport, alpha:Number) : void {
alpha *= this.alpha * skeleton.a;
var drawOrder:Vector.<Slot> = skeleton.drawOrder;
for (var i:int = 0, n:int = drawOrder.length; i < n; i++) {
var slot:Slot = drawOrder[i];
var regionAttachment:RegionAttachment = slot.attachment as RegionAttachment;
if (regionAttachment != null) {
var vertices:Vector.<Number> = this.vertices;
regionAttachment.computeWorldVertices(skeleton.x, skeleton.y, slot.bone, vertices);
var r:Number = skeleton.r * slot.r * 255;
var g:Number = skeleton.g * slot.g * 255;
var b:Number = skeleton.b * slot.b * 255;
var a:Number = slot.a;
var rgb:uint = Color.rgb(r,g,b);
var image:SkeletonImage = regionAttachment.rendererObject as SkeletonImage;
var vertexData:Vector.<Number> = image.vertexData.rawData;
image.vertexData.setPosition(0, vertices[2], vertices[3]);
image.vertexData.setColor(0, rgb);
image.vertexData.setAlpha(0, a);
image.vertexData.setPosition(1, vertices[4], vertices[5]);
image.vertexData.setColor(1, rgb);
image.vertexData.setAlpha(1, a);
image.vertexData.setPosition(2, vertices[0], vertices[1]);
image.vertexData.setColor(2, rgb);
image.vertexData.setAlpha(2, a);
image.vertexData.setPosition(3, vertices[6], vertices[7]);
image.vertexData.setColor(3, rgb);
image.vertexData.setAlpha(3, a);
image.updateVertices();
support.blendMode = slot.data.additiveBlending ? BlendMode.ADD : BlendMode.NORMAL;
support.batchQuad(image, alpha, image.texture);
}
else
{
var skeletonAttachment:SkeletonAttachment = slot.attachment as SkeletonAttachment;
if (skeletonAttachment != null) {
var skt:SkeletonAnimation = skeletonAttachment.skeletion;
if (skt.hasVisibleArea)
{
skt.x = slot.bone.worldX;
skt.y = slot.bone.worldY;
skt.rotation = slot.bone.worldRotation * (3.1415926) / 180;
skt.scaleX = slot.bone.worldScaleX;
skt.scaleY = slot.bone.worldScaleY;
skt.alpha = slot.a;
var filter:FragmentFilter = skt.filter;
support.pushMatrix();
support.transformMatrix(skt);
support.blendMode = skt.blendMode;
if (filter) filter.render(skt, support, alpha);
else skt.render(support, alpha);
support.blendMode = blendMode;
support.popMatrix();
}
}
}
}
}
Hope for response, Thanks!