mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[lua] 4.0 port fixes.
This commit is contained in:
parent
a5be08a62a
commit
6428b82e1e
@ -66,7 +66,7 @@ package spine.animation {
|
||||
return;
|
||||
}
|
||||
|
||||
var x : Number = 0, y : Number = 0;
|
||||
var x : Number, y : Number;
|
||||
var i : int = search(frames, time, ENTRIES);
|
||||
var curveType : Number = curves[i / ENTRIES];
|
||||
switch (curveType) {
|
||||
|
||||
@ -53,14 +53,14 @@ function loadSkeleton (jsonFile, atlasFile, animation, skin, scale, x, y)
|
||||
local stateData = spine.AnimationStateData.new(skeletonData)
|
||||
local state = spine.AnimationState.new(stateData)
|
||||
state:setAnimationByName(0, animation, true)
|
||||
if (jsonFile == "spineboy-pro") then
|
||||
if jsonFile == "spineboy-pro" then
|
||||
stateData:setMix("walk", "jump", 0.5)
|
||||
stateData:setMix("jump", "run", 0.5)
|
||||
state:addAnimationByName(0, "jump", false, 3)
|
||||
state:addAnimationByName(0, "run", true, 0)
|
||||
end
|
||||
|
||||
if (jsonFile == "raptor-pro") then
|
||||
if jsonFile == "raptor-pro" then
|
||||
swirl.centerY = -200
|
||||
skeleton.vertexEffect = swirl
|
||||
-- skeleton.vertexEffect = spine.JitterEffect.new(10, 10)
|
||||
@ -113,12 +113,12 @@ end
|
||||
function love.load(arg)
|
||||
if arg[#arg] == "-debug" then require("mobdebug").start() end
|
||||
skeletonRenderer = spine.SkeletonRenderer.new(true)
|
||||
table.insert(skeletons, loadSkeleton("spineboy-pro", "spineboy", "walk", nil, 0.5, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("goblins-pro", "goblins", "walk", "goblin", 1, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("mix-and-match-pro", "mix-and-match", "dance", nil, 0.5, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("spineboy-pro", "spineboy", "walk", nil, 0.5, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("stretchyman-pro", "stretchyman", "sneak", nil, 0.5, 200, 500))
|
||||
table.insert(skeletons, loadSkeleton("coin-pro", "coin", "animation", nil, 0.5, 400, 300))
|
||||
table.insert(skeletons, loadSkeleton("raptor-pro", "raptor", "walk", nil, 0.3, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("goblins-pro", "goblins", "walk", "goblin", 1, 400, 500))
|
||||
table.insert(skeletons, loadSkeleton("tank-pro", "tank", "drive", nil, 0.2, 600, 500))
|
||||
table.insert(skeletons, loadSkeleton("vine-pro", "vine", "grow", nil, 0.3, 400, 500))
|
||||
end
|
||||
@ -131,9 +131,9 @@ function love.update (delta)
|
||||
state:apply(skeleton)
|
||||
skeleton:updateWorldTransform()
|
||||
|
||||
if (skeleton.vertexEffect) then
|
||||
if skeleton.vertexEffect then
|
||||
skeletonRenderer.vertexEffect = skeleton.vertexEffect
|
||||
if (skeleton.vertexEffect == swirl) then
|
||||
if skeleton.vertexEffect == swirl then
|
||||
swirlTime = swirlTime + delta
|
||||
local percent = swirlTime % 2
|
||||
if (percent > 1) then percent = 1 - (percent - 1) end
|
||||
@ -148,7 +148,6 @@ function love.draw ()
|
||||
love.graphics.setBackgroundColor(0, 0, 0, 255)
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
local skeleton = skeletons[activeSkeleton].skeleton
|
||||
|
||||
skeletonRenderer:draw(skeleton)
|
||||
end
|
||||
|
||||
|
||||
@ -262,6 +262,7 @@ function Animation.CurveTimeline.new (timelineType, frameEntries, frameCount, be
|
||||
return y + (time - x) / (curves[i] - x) * (curves[i + 1] - y)
|
||||
end
|
||||
local n = i + BEZIER_SIZE
|
||||
i = i + 2
|
||||
while i < n do
|
||||
if curves[i] >= time then
|
||||
local x = curves[i - 2]
|
||||
@ -365,9 +366,10 @@ function Animation.RotateTimeline.new (frameCount, bezierCount, boneIndex)
|
||||
local r = self:getCurveValue(time)
|
||||
if blend == MixBlend.setup then
|
||||
bone.rotation = bone.data.rotation + r * alpha
|
||||
elseif blend == MixBlend.first or blend == MixBlend.replace then
|
||||
r = r + bone.data.rotation - bone.rotation
|
||||
elseif blend == MixBlend.add then
|
||||
else
|
||||
if blend == MixBlend.first or blend == MixBlend.replace then
|
||||
r = r + bone.data.rotation - bone.rotation
|
||||
end
|
||||
bone.rotation = bone.rotation + r * alpha
|
||||
end
|
||||
end
|
||||
@ -529,8 +531,8 @@ function Animation.ScaleTimeline.new (frameCount, bezierCount, boneIndex)
|
||||
return
|
||||
end
|
||||
|
||||
local x = 0
|
||||
local y = 0
|
||||
local x
|
||||
local y
|
||||
local i = search(frames, time, ENTRIES)
|
||||
local curveType = self.curves[math_floor(i / ENTRIES)]
|
||||
if curveType == LINEAR then
|
||||
|
||||
@ -61,20 +61,16 @@ function SkeletonJson.new (attachmentLoader)
|
||||
linkedMeshes = {}
|
||||
}
|
||||
|
||||
function self:readSkeletonDataFile (fileName, base)
|
||||
return self:readSkeletonData(utils.readFile(fileName, base))
|
||||
end
|
||||
|
||||
local readAttachment
|
||||
local readAnimation
|
||||
local readCurve
|
||||
local readTimeline1
|
||||
local readTimeline2
|
||||
local getArray
|
||||
local getValue
|
||||
|
||||
local getValue = function (map, name, default)
|
||||
local value = map[name]
|
||||
if value == nil then return default else return value end
|
||||
function self:readSkeletonDataFile (fileName, base)
|
||||
return self:readSkeletonData(utils.readFile(fileName, base))
|
||||
end
|
||||
|
||||
function self:readSkeletonData (jsonText)
|
||||
@ -981,6 +977,7 @@ function SkeletonJson.new (attachmentLoader)
|
||||
local time = getValue(keyMap, "time", 0)
|
||||
local bezier = 0
|
||||
for i,keyMap in ipairs(timelineMap) do
|
||||
local frame = i - 1
|
||||
local deform = nil
|
||||
local verticesValue = getValue(keyMap, "vertices", nil)
|
||||
if verticesValue == nil then
|
||||
@ -1007,7 +1004,6 @@ function SkeletonJson.new (attachmentLoader)
|
||||
end
|
||||
end
|
||||
end
|
||||
local frame = i - 1
|
||||
timeline:setFrame(frame, time, deform)
|
||||
local nextMap = timelineMap[frame + 1]
|
||||
if not nextMap then
|
||||
@ -1200,6 +1196,11 @@ function SkeletonJson.new (attachmentLoader)
|
||||
return values
|
||||
end
|
||||
|
||||
getValue = function (map, name, default)
|
||||
local value = map[name]
|
||||
if value == nil then return default else return value end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
return SkeletonJson
|
||||
|
||||
@ -88,7 +88,7 @@ function TextureAtlas:parse (atlasContent, imageLoader)
|
||||
|
||||
local colon = line:find(":")
|
||||
if not colon then return 0 end
|
||||
entry[0] = trim(line:sub(1, colon))
|
||||
entry[0] = trim(line:sub(1, colon - 1))
|
||||
local lastMatch = colon + 1
|
||||
local i = 1
|
||||
while true do
|
||||
@ -97,7 +97,7 @@ function TextureAtlas:parse (atlasContent, imageLoader)
|
||||
entry[i] = trim(line:sub(lastMatch))
|
||||
return i
|
||||
end
|
||||
entry[i] = trim(line:sub(lastMatch, comma - lastMatch))
|
||||
entry[i] = trim(line:sub(lastMatch, comma - 1))
|
||||
lastMatch = comma + 1
|
||||
if i == 4 then return 4 end
|
||||
i = i + 1
|
||||
|
||||
@ -566,7 +566,7 @@ module spine {
|
||||
return;
|
||||
}
|
||||
|
||||
let x = 0, y = 0;
|
||||
let x, y;
|
||||
let i = Timeline.search(frames, time, 3/*ENTRIES*/);
|
||||
let curveType = this.curves[i / 3/*ENTRIES*/];
|
||||
switch (curveType) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user