mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[lua] Added mix-and-match example. See #1375.
This commit is contained in:
parent
2946cec9d1
commit
ee32f30545
@ -102,6 +102,23 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
|
||||
--skeleton.vertexEffect = spine.JitterEffect.new(5, 5)
|
||||
skeleton.vertexEffect = swirl
|
||||
animationState:setAnimationByName(0, animation, true)
|
||||
elseif jsonFile == "mix-and-match-pro.json" then
|
||||
-- Create a new skin, by mixing and matching other skins
|
||||
-- that fit together. Items making up the girl are individual
|
||||
-- skins. Using the skin API, a new skin is created which is
|
||||
-- a combination of all these individual item skins.
|
||||
local skin = spine.Skin.new("mix-and-match")
|
||||
skin:addSkin(skeletonData:findSkin("skin-base"))
|
||||
skin:addSkin(skeletonData:findSkin("nose/short"))
|
||||
skin:addSkin(skeletonData:findSkin("eyes/eyelids-girly"))
|
||||
skin:addSkin(skeletonData:findSkin("eyes/violet"))
|
||||
skin:addSkin(skeletonData:findSkin("hair/brown"))
|
||||
skin:addSkin(skeletonData:findSkin("clothes/hoodie-orange"))
|
||||
skin:addSkin(skeletonData:findSkin("legs/pants-jeans"))
|
||||
skin:addSkin(skeletonData:findSkin("accessories/bag"))
|
||||
skin:addSkin(skeletonData:findSkin("accessories/hat-red-yellow"))
|
||||
skeleton:setSkinByReference(skin)
|
||||
animationState:setAnimationByName(0, animation, true)
|
||||
else
|
||||
animationState:setAnimationByName(0, animation, true)
|
||||
end
|
||||
@ -110,6 +127,7 @@ function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
|
||||
return { skeleton = skeleton, state = animationState }
|
||||
end
|
||||
|
||||
table.insert(skeletons, loadSkeleton("mix-and-match.atlas", "mix-and-match-pro.json", 240, 300, 0.3, "dance"))
|
||||
table.insert(skeletons, loadSkeleton("spineboy.atlas", "spineboy-pro.json", 240, 300, 0.4, "walk"))
|
||||
table.insert(skeletons, loadSkeleton("stretchyman.atlas", "stretchyman-stretchy-ik-pro.json", 40, 300, 0.5, "sneak"))
|
||||
table.insert(skeletons, loadSkeleton("coin.atlas", "coin-pro.json", 240, 160, 0.4, "animation"))
|
||||
|
||||
@ -65,6 +65,24 @@ function loadSkeleton (jsonFile, atlasFile, animation, skin, scale, x, y)
|
||||
skeleton.vertexEffect = swirl
|
||||
-- skeleton.vertexEffect = spine.JitterEffect.new(10, 10)
|
||||
end
|
||||
|
||||
if jsonFile == "mix-and-match-pro" then
|
||||
-- Create a new skin, by mixing and matching other skins
|
||||
-- that fit together. Items making up the girl are individual
|
||||
-- skins. Using the skin API, a new skin is created which is
|
||||
-- a combination of all these individual item skins.
|
||||
local skin = spine.Skin.new("mix-and-match")
|
||||
skin:addSkin(skeletonData:findSkin("skin-base"))
|
||||
skin:addSkin(skeletonData:findSkin("nose/short"))
|
||||
skin:addSkin(skeletonData:findSkin("eyes/eyelids-girly"))
|
||||
skin:addSkin(skeletonData:findSkin("eyes/violet"))
|
||||
skin:addSkin(skeletonData:findSkin("hair/brown"))
|
||||
skin:addSkin(skeletonData:findSkin("clothes/hoodie-orange"))
|
||||
skin:addSkin(skeletonData:findSkin("legs/pants-jeans"))
|
||||
skin:addSkin(skeletonData:findSkin("accessories/bag"))
|
||||
skin:addSkin(skeletonData:findSkin("accessories/hat-red-yellow"))
|
||||
skeleton:setSkinByReference(skin)
|
||||
end
|
||||
|
||||
-- set some event callbacks
|
||||
state.onStart = function (entry)
|
||||
@ -95,6 +113,7 @@ end
|
||||
function love.load(arg)
|
||||
if arg[#arg] == "-debug" then require("mobdebug").start() end
|
||||
skeletonRenderer = spine.SkeletonRenderer.new(true)
|
||||
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.3, 200, 500))
|
||||
table.insert(skeletons, loadSkeleton("coin-pro", "coin", "animation", nil, 0.5, 400, 300))
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
-- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local utils = require "spine-lua.utils"
|
||||
local Bone = require "spine-lua.Bone"
|
||||
local Slot = require "spine-lua.Slot"
|
||||
local IkConstraint = require "spine-lua.IkConstraint"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user