mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
baa70fa810
@ -413,9 +413,16 @@ function Animation.AttachmentTimeline.new ()
|
||||
end
|
||||
|
||||
local attachmentName = self.attachmentNames[frameIndex]
|
||||
local attachment
|
||||
if attachmentName then attachment = skeleton:getAttachment(self.slotName, attachmentName) end
|
||||
skeleton:findSlot(self.slotName):setAttachment(attachment)
|
||||
local slot = skeleton.slotsByName[self.slotName]
|
||||
if attachmentName then
|
||||
if not slot.attachment then
|
||||
slot:setAttachment(skeleton:getAttachment(self.slotName, attachmentName))
|
||||
elseif slot.attachment.name ~= attachmentName then
|
||||
slot:setAttachment(skeleton:getAttachment(self.slotName, attachmentName))
|
||||
end
|
||||
else
|
||||
slot:setAttachment(nil)
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
|
||||
@ -35,6 +35,7 @@ function Skeleton.new (skeletonData)
|
||||
data = skeletonData,
|
||||
bones = {},
|
||||
slots = {},
|
||||
slotsByName = {},
|
||||
drawOrder = {}
|
||||
}
|
||||
|
||||
@ -73,13 +74,10 @@ function Skeleton.new (skeletonData)
|
||||
return nil
|
||||
end
|
||||
|
||||
function self:findSlot (slotName)
|
||||
if not slotName then error("slotName cannot be nil.", 2) end
|
||||
for i,slot in ipairs(self.slots) do
|
||||
if slot.data.name == slotName then return slot end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
function self:findSlot (slotName)
|
||||
if not slotName then error("slotName cannot be nil.", 2) end
|
||||
return slotsByName[slotName]
|
||||
end
|
||||
|
||||
function self:setSkin (skinName)
|
||||
local newSkin
|
||||
@ -106,7 +104,7 @@ function Skeleton.new (skeletonData)
|
||||
function self:getAttachment (slotName, attachmentName)
|
||||
if not slotName then error("slotName cannot be nil.", 2) end
|
||||
if not attachmentName then error("attachmentName cannot be nil.", 2) end
|
||||
local slotIndex = self.data:findSlotIndex(slotName)
|
||||
local slotIndex = skeletonData.slotNameIndices[slotName]
|
||||
if slotIndex == -1 then error("Slot not found: " .. slotName, 2) end
|
||||
if self.skin then
|
||||
local attachment = self.skin:getAttachment(slotIndex, attachmentName)
|
||||
@ -147,6 +145,7 @@ function Skeleton.new (skeletonData)
|
||||
local bone = self.bones[spine.utils.indexOf(skeletonData.bones, slotData.boneData)]
|
||||
local slot = Slot.new(slotData, self, bone)
|
||||
table.insert(self.slots, slot)
|
||||
self.slotsByName[slot.data.name] = slot
|
||||
table.insert(self.drawOrder, slot)
|
||||
end
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ function SkeletonData.new ()
|
||||
local self = {
|
||||
bones = {},
|
||||
slots = {},
|
||||
slotNameIndices = {},
|
||||
skins = {},
|
||||
animations = {}
|
||||
}
|
||||
@ -58,10 +59,7 @@ function SkeletonData.new ()
|
||||
|
||||
function self:findSlotIndex (slotName)
|
||||
if not slotName then error("slotName cannot be nil.", 2) end
|
||||
for i,slot in ipairs(self.slots) do
|
||||
if slot.name == slotName then return i end
|
||||
end
|
||||
return -1
|
||||
return slotNameIndices[slotName] or -1
|
||||
end
|
||||
|
||||
function self:findSkin (skinName)
|
||||
|
||||
@ -29,7 +29,6 @@ local SlotData = require "spine-lua.SlotData"
|
||||
local Skin = require "spine-lua.Skin"
|
||||
local AttachmentLoader = require "spine-lua.AttachmentLoader"
|
||||
local Animation = require "spine-lua.Animation"
|
||||
|
||||
local TIMELINE_SCALE = "scale"
|
||||
local TIMELINE_ROTATE = "rotate"
|
||||
local TIMELINE_TRANSLATE = "translate"
|
||||
@ -102,8 +101,9 @@ function SkeletonJson.new (attachmentLoader)
|
||||
end
|
||||
|
||||
slotData.attachmentName = slotMap["attachment"]
|
||||
|
||||
table.insert(skeletonData.slots, slotData)
|
||||
table.insert(skeletonData.slots, slotData)
|
||||
skeletonData.slotNameIndices[slotData.name] = #skeletonData.slots
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -113,7 +113,7 @@ function SkeletonJson.new (attachmentLoader)
|
||||
for skinName,skinMap in pairs(map) do
|
||||
local skin = Skin.new(skinName)
|
||||
for slotName,slotMap in pairs(skinMap) do
|
||||
local slotIndex = skeletonData:findSlotIndex(slotName)
|
||||
local slotIndex = skeletonData.slotNameIndices[slotName]
|
||||
for attachmentName,attachmentMap in pairs(slotMap) do
|
||||
local attachment = readAttachment(attachmentName, attachmentMap, self.scale)
|
||||
if attachment then
|
||||
@ -213,7 +213,7 @@ function SkeletonJson.new (attachmentLoader)
|
||||
local slotsMap = map["slots"]
|
||||
if slotsMap then
|
||||
for slotName,timelineMap in pairs(slotsMap) do
|
||||
local slotIndex = skeletonData:findSlotIndex(slotName)
|
||||
local slotIndex = skeletonData.slotNameIndices[slotName]
|
||||
|
||||
for timelineName,values in pairs(timelineMap) do
|
||||
if timelineName == TIMELINE_COLOR then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user