Look in skin before default skin.

This commit is contained in:
NathanSweet 2013-03-15 02:25:15 +01:00
parent 5fdcfaca2e
commit 43018798ab
3 changed files with 3 additions and 3 deletions

View File

@ -143,11 +143,11 @@ function Skeleton.new (skeletonData, group)
if not attachmentName then error("attachmentName cannot be nil.", 2) end
local slotIndex = self.data:findSlotIndex(slotName)
if slotIndex == -1 then error("Slot not found: " .. slotName, 2) end
if self.skin then return self.skin:getAttachment(slotIndex, attachmentName) end
if self.data.defaultSkin then
local attachment = self.data.defaultSkin:getAttachment(slotIndex, attachmentName)
if attachment then return attachment end
end
if self.skin then return self.skin:getAttachment(slotIndex, attachmentName) end
return nil
end

View File

@ -132,11 +132,11 @@ Attachment* BaseSkeleton::getAttachment (const string &slotName, const string &a
}
Attachment* BaseSkeleton::getAttachment (int slotIndex, const string &attachmentName) const {
if (skin) return skin->getAttachment(slotIndex, attachmentName);
if (data->defaultSkin) {
Attachment *attachment = data->defaultSkin->getAttachment(slotIndex, attachmentName);
if (attachment) return attachment;
}
if (skin) return skin->getAttachment(slotIndex, attachmentName);
return 0;
}

View File

@ -216,11 +216,11 @@ public class Skeleton {
/** @return May be null. */
public Attachment getAttachment (int slotIndex, String attachmentName) {
if (attachmentName == null) throw new IllegalArgumentException("attachmentName cannot be null.");
if (skin != null) return skin.getAttachment(slotIndex, attachmentName);
if (data.defaultSkin != null) {
Attachment attachment = data.defaultSkin.getAttachment(slotIndex, attachmentName);
if (attachment != null) return attachment;
}
if (skin != null) return skin.getAttachment(slotIndex, attachmentName);
return null;
}