beginner - problems applying an animation with spine

Hello

I’m having problems with applying an animation to a skeleton with Spine. The skeleton just picks up the first frame of the sequence. Not sure what I am missing.

The topics I have read in forums also show

[lua]walkAnimation:apply(skeleton, animationTime, true )[/lua]

I’ve found that I can’t set true for loops otherwise I get the error. “attempt to compare boolean with number”

It appears I need to set the number of loops

Help!

[lua] local spine = require “spine-corona.spine”

local json = spine.SkeletonJson.new()

json.scale = 1

local skeletonData = json:readSkeletonDataFile(“examples/spineboy/spineboy.json”)

local skeleton = spine.Skeleton.new(skeletonData)

function skeleton:createImage (attachment)

    – Customize where images are loaded.

    return display.newImage(“examples/spineboy/images/” … attachment.name … “.png”)

end

skeleton.group.x = 150

skeleton.group.y = 325

skeleton.flipX = false

skeleton.flipY = false

skeleton.debug = false – Omit or set to false to not draw debug lines on top of the images.

skeleton.debugAabb = false

skeleton:setToSetupPose()

local walkAnimation = skeletonData:findAnimation(“walk”)

local jumpAnimation = skeletonData:findAnimation(“jump”)

local lastTime = 0

local playAnimation = true

local animationTime = 0

Runtime:addEventListener(“enterFrame”, function (event)

    – Compute time in seconds since last frame.

    local currentTime = event.time / 1000

    local delta = currentTime - lastTime

    lastTime = currentTime

    animationTime = animationTime + delta

    

    --Pose skeleton using animation.

    if playAnimation == true then

        walkAnimation:apply(skeleton, animationTime, 10 )

        skeleton:updateWorldTransform()

    end

end)[/lua]

Try it

local lastTime = 0 Runtime:addEventListener("enterFrame", function (event))     local currentTime = event.time/1000     lastTime = currentTime              walkAnimation:apply(skeleton, lastTime, currentTime, true, 0, 0.8) skeleton:updateWorldTransform()     end)    

Thanks Julio, works perfectly.

Very Appreciated

Cheers

No problem, I’m stocked it could help you,

Also you should Check this link if you want use setAnimationByName and have animation queued :

http://forums.coronalabs.com/topic/45618-cant-get-spine-examples-to-work-with-current-build-20142189/

Hope it help you

Try it

local lastTime = 0 Runtime:addEventListener("enterFrame", function (event))     local currentTime = event.time/1000     lastTime = currentTime              walkAnimation:apply(skeleton, lastTime, currentTime, true, 0, 0.8) skeleton:updateWorldTransform()     end)    

Thanks Julio, works perfectly.

Very Appreciated

Cheers

No problem, I’m stocked it could help you,

Also you should Check this link if you want use setAnimationByName and have animation queued :

http://forums.coronalabs.com/topic/45618-cant-get-spine-examples-to-work-with-current-build-20142189/

Hope it help you