[spine-libgdx] Fixed Skeleton copy constructor.

This commit is contained in:
NathanSweet 2016-07-04 02:13:45 +02:00
parent 0a08704ee8
commit fca7c478e2
2 changed files with 10 additions and 3 deletions

View File

@ -62,7 +62,7 @@ public class Bone implements Updatable {
setToSetupPose();
}
/** Copy constructor.
/** Copy constructor. Does not copy the children bones.
* @param parent May be null. */
public Bone (Bone bone, Skeleton skeleton, Bone parent) {
if (bone == null) throw new IllegalArgumentException("bone cannot be null.");

View File

@ -107,8 +107,15 @@ public class Skeleton {
bones = new Array(skeleton.bones.size);
for (Bone bone : skeleton.bones) {
Bone parent = bone.parent == null ? null : bones.get(bone.parent.data.index);
bones.add(new Bone(bone, this, parent));
Bone copy;
if (bone.parent == null)
copy = new Bone(bone, this, null);
else {
Bone parent = bones.get(bone.parent.data.index);
copy = new Bone(bone, this, parent);
parent.children.add(copy);
}
bones.add(copy);
}
slots = new Array(skeleton.slots.size);