• Runtimes
  • Corona SDK: Completing an animation before going to the next

  • Изменено
Related Discussions
...

Hi,

I am running into an issue but not sure how to fix it. The issue that I am having is when I switch from one animation I would like the animation to complete first before going to the next animation.
example:
I have a player that is running and when I tap on the fire button the player shots beams from its hands but I have to hold down the fire button in order for the fire animation to complete.

I have used the mix function but it does not work, here is some of my code:

function ChangeAnimation()


         if(LoadPlayer.animationType == "idle") then
            AnimationIdle:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
         elseif(LoadPlayer.animationType == "run") then               
             AnimationRun:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        elseif(LoadPlayer.animationType == "Jump") then               
             AnimationJump:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        elseif(LoadPlayer.animationType == "idle-Shooting_Up") then
           AnimationRunShootingUp:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        elseif(LoadPlayer.animationType == "Run-Shooting_Forward") then
            AnimationRunShootingforward:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        elseif(LoadPlayer.animationType == "Crouch") then
            AnimationCrouch:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        elseif(LoadPlayer.animationType == "Run-Shooting_135") then
            AnimationRunShooting_135:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        elseif(LoadPlayer.animationType == "Run-Shooting_45") then
            AnimationRunShooting_45:mix(skeleton, LoadPlayer.animationTime, true, 0.75)
        end

        skeleton:updateWorldTransform()
        
       
   end


    Runtime:addEventListener("enterFrame", function (event)


Compute time in seconds since last frame.
local currentTime = event.time / 1000
local delta = currentTime - LoadPlayer.lastTime
LoadPlayer.lastTime = currentTime



Accumulate time and pose skeleton using animation.
LoadPlayer.animationTime = LoadPlayer.animationTime + delta


        ChangeAnimation()
           
   end)

Any help would greatly be appreciated.

JCP

JCP_13 написал

I have used the mix function but it does not work

What doesn't work about it?

It sounds like you want to wait until the current animation is complete (time >= animation.duration) before setting the next animation.

You can try using AnimationState for managing mixing and queuing animations.
http://esotericsoftware.com/spine-using ... ationstate

Nate написал
JCP_13 написал

I have used the mix function but it does not work

What doesn't work about it?

It sounds like you want to wait until the current animation is complete (time >= animation.duration) before setting the next animation.

You can try using AnimationState for managing mixing and queuing animations.
http://esotericsoftware.com/spine-using ... ationstate

Sorry if my question sounds so junior I am still very new to this and do not completely understand all the terminology and functions; is it possible to do a video about how to do this? if you do not have the bandwidth I would be happy to do it if you would help guide me a bit.

I will try your suggestion and get back to you.

Thanks,

JCP

Nate написал
JCP_13 написал

I have used the mix function but it does not work

What doesn't work about it?

It sounds like you want to wait until the current animation is complete (time >= animation.duration) before setting the next animation.

You can try using AnimationState for managing mixing and queuing animations.
http://esotericsoftware.com/spine-using ... ationstate

Hi Nate,

I have tried using the code snippet you provided as well as the AnimationState Example but I can't seem to get it to work, the animation just freezes.

What I am trying to do:
I have a Virtual JoyStick left, right, Jump, and Fire. When no buttons are pressed the player is idle, when right button is touched the player runs and when button Jump is touched it jumps and so forth.
I have that work but the transitions are not smooth at all and when you touch one button to the next, the animation does not complete; it all looks very choppy and incomplete 🙁 . I've tried a few different ways but nothing really worked well :angry: .

Is it possible for you to create a working example (in Corona SDK) of what I just explained? I know there is something that I am missing but not sure what that is. Also, I think it would help a lot of other people out there too.

Thank you in advance,

JCP

Nate написал

The Corona example shows how to use AnimationState:
https://github.com/EsotericSoftware/spi ... in.lua#L26

What have you tried?

Hi Nate,

Sorry to bother you with this but I have sent you the project by email so you can take a look at the code.

Thank you for the help 🙂

JCP

6 дней спустя

Hi Nate,

Any insight to what I maybe doing wrong?

Thanks.

Many things I'm afraid. 😉 I replied via email. Sorry for the long delay!

Nate написал

Many things I'm afraid. 😉 I replied via email. Sorry for the long delay!

Thank you Nate for looking into this for me, I know you're very busy so I really appreciate it. We are with you dudes and we know it is challenging with just the two of you. So please, keep up the fantastic work, both of you!!!

Once I get everything working I will post the results.

Thanks again,

JCP

Thanks! 🙂 Really I like helping, it's just the more involved it is for me the more I tend to prioritize other, easier to finish tasks ahead of it. This is why people should try to ask the most specific questions possible. Play around with a simple app and if something specific isn't making sense, that is a lot easier for me to help with than an entire application. 🙂