mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[lua] Added event volume and balance, see #1171.
This commit is contained in:
parent
ab3dcb0823
commit
751c6e23db
@ -90,7 +90,7 @@ cp -f ../raptor/export/raptor-pro.json ../../spine-corona/data
|
|||||||
cp -f ../raptor/export/raptor.atlas ../../spine-corona/data
|
cp -f ../raptor/export/raptor.atlas ../../spine-corona/data
|
||||||
cp -f ../raptor/export/raptor.png ../../spine-corona/data
|
cp -f ../raptor/export/raptor.png ../../spine-corona/data
|
||||||
|
|
||||||
cp -f ../spineboy/export/spineboy-ess.json ../../spine-corona/data
|
cp -f ../spineboy/export/spineboy-pro.json ../../spine-corona/data
|
||||||
cp -f ../spineboy/export/spineboy.atlas ../../spine-corona/data
|
cp -f ../spineboy/export/spineboy.atlas ../../spine-corona/data
|
||||||
cp -f ../spineboy/export/spineboy.png ../../spine-corona/data
|
cp -f ../spineboy/export/spineboy.png ../../spine-corona/data
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ cp -f ../raptor/export/raptor-pro.json ../../spine-love/data
|
|||||||
cp -f ../raptor/export/raptor.atlas ../../spine-love/data
|
cp -f ../raptor/export/raptor.atlas ../../spine-love/data
|
||||||
cp -f ../raptor/export/raptor.png ../../spine-love/data
|
cp -f ../raptor/export/raptor.png ../../spine-love/data
|
||||||
|
|
||||||
cp -f ../spineboy/export/spineboy-ess.json ../../spine-love/data
|
cp -f ../spineboy/export/spineboy-pro.json ../../spine-love/data
|
||||||
cp -f ../spineboy/export/spineboy.atlas ../../spine-love/data
|
cp -f ../spineboy/export/spineboy.atlas ../../spine-love/data
|
||||||
cp -f ../spineboy/export/spineboy.png ../../spine-love/data
|
cp -f ../spineboy/export/spineboy.png ../../spine-love/data
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-corona/data/spineboy-pro.json
Normal file
1
spine-corona/data/spineboy-pro.json
Normal file
File diff suppressed because one or more lines are too long
@ -60,7 +60,7 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
|
|||||||
print(entry.trackIndex.." dispose: "..entry.animation.name)
|
print(entry.trackIndex.." dispose: "..entry.animation.name)
|
||||||
end
|
end
|
||||||
animationState.onEvent = function (entry, event)
|
animationState.onEvent = function (entry, event)
|
||||||
print(entry.trackIndex.." event: "..entry.animation.name..", "..event.data.name..", "..event.intValue..", "..event.floatValue..", '"..(event.stringValue or "").."'")
|
print(entry.trackIndex.." event: "..entry.animation.name..", "..event.data.name..", "..event.intValue..", "..event.floatValue..", '"..(event.stringValue or "").."'" .. ", " .. event.volume .. ", " .. event.balance)
|
||||||
end
|
end
|
||||||
|
|
||||||
if atlasFile == "spineboy.atlas" then
|
if atlasFile == "spineboy.atlas" then
|
||||||
@ -81,9 +81,9 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
|
|||||||
return { skeleton = skeleton, state = animationState }
|
return { skeleton = skeleton, state = animationState }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table.insert(skeletons, loadSkeleton("spineboy.atlas", "spineboy-pro.json", 240, 300, 0.4, "walk"))
|
||||||
table.insert(skeletons, loadSkeleton("stretchyman.atlas", "stretchyman-stretchy-ik.json", 40, 300, 0.5, "sneak"))
|
table.insert(skeletons, loadSkeleton("stretchyman.atlas", "stretchyman-stretchy-ik.json", 40, 300, 0.5, "sneak"))
|
||||||
table.insert(skeletons, loadSkeleton("coin.atlas", "coin-pro.json", 240, 300, 0.4, "rotate"))
|
table.insert(skeletons, loadSkeleton("coin.atlas", "coin-pro.json", 240, 300, 0.4, "rotate"))
|
||||||
table.insert(skeletons, loadSkeleton("spineboy.atlas", "spineboy-ess.json", 240, 300, 0.4, "walk"))
|
|
||||||
table.insert(skeletons, loadSkeleton("raptor.atlas", "raptor-pro.json", 200, 300, 0.25, "walk"))
|
table.insert(skeletons, loadSkeleton("raptor.atlas", "raptor-pro.json", 200, 300, 0.25, "walk"))
|
||||||
table.insert(skeletons, loadSkeleton("goblins.atlas", "goblins-pro.json", 240, 300, 0.8, "walk", "goblin"))
|
table.insert(skeletons, loadSkeleton("goblins.atlas", "goblins-pro.json", 240, 300, 0.8, "walk", "goblin"))
|
||||||
table.insert(skeletons, loadSkeleton("stretchyman.atlas", "stretchyman-pro.json", 40, 300, 0.5, "sneak"))
|
table.insert(skeletons, loadSkeleton("stretchyman.atlas", "stretchyman-pro.json", 40, 300, 0.5, "sneak"))
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-love/data/spineboy-pro.json
Normal file
1
spine-love/data/spineboy-pro.json
Normal file
File diff suppressed because one or more lines are too long
@ -84,7 +84,7 @@ function loadSkeleton (jsonFile, atlasFile, animation, skin, scale, x, y)
|
|||||||
print(entry.trackIndex.." dispose: "..entry.animation.name)
|
print(entry.trackIndex.." dispose: "..entry.animation.name)
|
||||||
end
|
end
|
||||||
state.onEvent = function (entry, event)
|
state.onEvent = function (entry, event)
|
||||||
print(entry.trackIndex.." event: "..entry.animation.name..", "..event.data.name..", "..event.intValue..", "..event.floatValue..", '"..(event.stringValue or "").."'")
|
print(entry.trackIndex.." event: "..entry.animation.name..", "..event.data.name..", "..event.intValue..", "..event.floatValue..", '"..(event.stringValue or "").."'" .. ", " .. event.volume .. ", " .. event.balance)
|
||||||
end
|
end
|
||||||
|
|
||||||
state:update(0.5)
|
state:update(0.5)
|
||||||
@ -96,9 +96,9 @@ end
|
|||||||
function love.load(arg)
|
function love.load(arg)
|
||||||
if arg[#arg] == "-debug" then require("mobdebug").start() end
|
if arg[#arg] == "-debug" then require("mobdebug").start() end
|
||||||
skeletonRenderer = spine.SkeletonRenderer.new(true)
|
skeletonRenderer = spine.SkeletonRenderer.new(true)
|
||||||
|
table.insert(skeletons, loadSkeleton("spineboy-pro", "spineboy", "walk", nil, 0.5, 400, 500))
|
||||||
table.insert(skeletons, loadSkeleton("stretchyman-pro", "stretchyman", "sneak", nil, 0.3, 200, 500))
|
table.insert(skeletons, loadSkeleton("stretchyman-pro", "stretchyman", "sneak", nil, 0.3, 200, 500))
|
||||||
table.insert(skeletons, loadSkeleton("coin-pro", "coin", "rotate", nil, 0.5, 400, 500))
|
table.insert(skeletons, loadSkeleton("coin-pro", "coin", "rotate", nil, 0.5, 400, 500))
|
||||||
table.insert(skeletons, loadSkeleton("spineboy-ess", "spineboy", "walk", nil, 0.5, 400, 500))
|
|
||||||
table.insert(skeletons, loadSkeleton("raptor-pro", "raptor", "walk", nil, 0.3, 400, 500))
|
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("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("tank-pro", "tank", "drive", nil, 0.2, 600, 500))
|
||||||
|
|||||||
@ -1240,10 +1240,10 @@ function Animation.IkConstraintTimeline.new (frameCount)
|
|||||||
if (math_floor(frames[zlen(frames) + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
if (math_floor(frames[zlen(frames) + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
constraint.mix = constraint.mix + (frames[frames.length + PREV_MIX] - constraint.mix) * alpha;
|
constraint.mix = constraint.mix + (frames[zlen(frames) + PREV_MIX] - constraint.mix) * alpha;
|
||||||
if direction == MixDirection._in then
|
if direction == MixDirection._in then
|
||||||
constraint.bendDirection = math_floor(frames[zlen(frames) + PREV_BEND_DIRECTION])
|
constraint.bendDirection = math_floor(frames[zlen(frames) + PREV_BEND_DIRECTION])
|
||||||
if (math_floor(frames[zlen(frames) + PREV_COMPRES]) == 1) then constraint.compress = true else constraint.compress = false end
|
if (math_floor(frames[zlen(frames) + PREV_COMPRESS]) == 1) then constraint.compress = true else constraint.compress = false end
|
||||||
if (math_floor(frames[zlen(frames) + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
if (math_floor(frames[zlen(frames) + PREV_STRETCH]) == 1) then constraint.stretch = true else constraint.stretch = false end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,7 +37,9 @@ function Event.new (time, data)
|
|||||||
intValue = 0,
|
intValue = 0,
|
||||||
floatValue = 0,
|
floatValue = 0,
|
||||||
stringValue = nil,
|
stringValue = nil,
|
||||||
time = time
|
time = time,
|
||||||
|
volume = 1,
|
||||||
|
balance = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -36,7 +36,10 @@ function EventData.new (name)
|
|||||||
name = name,
|
name = name,
|
||||||
intValue = 0,
|
intValue = 0,
|
||||||
floatValue = 0,
|
floatValue = 0,
|
||||||
stringValue = nil
|
stringValue = nil,
|
||||||
|
audioPath = nil,
|
||||||
|
volume = 1,
|
||||||
|
balance = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -274,6 +274,11 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
data.intValue = getValue(eventMap, "int", 0)
|
data.intValue = getValue(eventMap, "int", 0)
|
||||||
data.floatValue = getValue(eventMap, "float", 0)
|
data.floatValue = getValue(eventMap, "float", 0)
|
||||||
data.stringValue = getValue(eventMap, "string", "")
|
data.stringValue = getValue(eventMap, "string", "")
|
||||||
|
data.audioPath = getValue(eventMap, "audio", nil)
|
||||||
|
if data.audioPath ~= nil then
|
||||||
|
data.volume = getValue(eventMap, "volume", 1)
|
||||||
|
data.balance = getValue(eventMap, "balance", 0)
|
||||||
|
end
|
||||||
table_insert(skeletonData.events, data)
|
table_insert(skeletonData.events, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -826,6 +831,10 @@ function SkeletonJson.new (attachmentLoader)
|
|||||||
else
|
else
|
||||||
event.stringValue = eventData.stringValue
|
event.stringValue = eventData.stringValue
|
||||||
end
|
end
|
||||||
|
if eventData.audioPath ~= nil then
|
||||||
|
event.volume = getValue(eventMap, "volume", 1)
|
||||||
|
event.balance = getValue(eventMap, "balance", 0)
|
||||||
|
end
|
||||||
timeline:setFrame(frameIndex, event)
|
timeline:setFrame(frameIndex, event)
|
||||||
frameIndex = frameIndex + 1
|
frameIndex = frameIndex + 1
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user