Nate написавThe rotation looks correct, I expect the translation is off. Are you positioning the CCSprite using both slot->bone->worldX/Y
and attachment->x/y
?
Yes, you are right, the rotation is right but the position is wrong. Here is my code for positioning CCSprite:
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
float *vertices = (float*)malloc(sizeof(float) * 10);
spRegionAttachment_computeWorldVertices(attachment,slot->bone,vertices);
for (int ii = 0; ii < 8; ii += 2) {
float x = vertices[ii], y = vertices[ii + 1];
minX = min(minX, x);
minY = min(minY, y);
maxX = max(maxX, x);
maxY = max(maxY, y);
}
CGPoint point = ccp((maxX + minX) *0.5, (maxY + minY) *0.5);
free(vertices);
point = [_skeleton convertToWorldSpace:point];
point = [batchNode convertToNodeSpace:point];
sprite.position = point;
Can you show me some details about positioning of the CCSprite using both slot->bone->worldX/Y
and attachment->x/y
? I don't know how, thank you.
The rotation looks correct on above, but the rotation angle of some bones are not right when I test another one.
Loading Image
The right is the spine skeleton, which is right.
The left are the sprites I created from the skeleton, the rotation angle of some bones are still not right, such as the neck, the right hand. I don't know why.
Thanks!