How Spine works with corona?

Thank you guys. Sorry I am sorry for the delay, i am in vacation with limited Internet. I cannot wait to get home and play with Spine (don’t tell my wife:). Thanks Nail, you ibot looks phenomenal!

I will have a million more questions when I get back online!

Mo [import]uid: 100814 topic_id: 36022 reply_id: 143275[/import]

Thanks xnailbender you answered my questions I had about Spine too. I tried it for a few mins and backed them on kickstarter so no Runtimes for me until they release it on GitHub or Saturday when the kickstarter ends. Spine is an amazing tool! [import]uid: 58885 topic_id: 36022 reply_id: 143279[/import]

Hey Mo,

I think they are working on documentation, there’s not much now. If you go to their site and browse the forum, there are some insights to glean.

Not sure if you saw my post, you didn’t leave a comment so no idea. Take a look at the video I made of my Super iBot integration. I think you’ll like what you see. You’ll also want to read the thread.

Super iBot created with Spine thread

Since my app was built and working, even though it looks like a simple platformer, there is a lot going on with the iBot. So what I basically did was set the static iBot .png to a .01 alpha after I got it working. If I stumble, I go back and set the iBot .png alpha to 1 so I can see where the animation should be. Anyways, basically the animations coordinates track the iBot .png’s x & y coordinates.

It actually works quite well to have an easily visible “marker” showing where the animation should be playing and I’ll use this technique on new projects, it really helps a newb like me.

You want to study the main.lua that comes with the spineboy example. You’ll see what’s going on there. I used it as a template to integrate.

Ok, that should cover the integration concept, so here’s basically how it works.

First I created a new module to hold everything… mySpine.lua :slight_smile:

Then you load the skeleton data for the animation. I only have 1 character, my iBot, so I only have 1 Setup pose that contains all the “bones” and data relating to the basic pose.

local skeletonData = json:readSkeletonDataFile("data/YourSkeleton.json")

Then you create the “AnimationObject” I guess it would be called.

YourAnimationObject = json:readAnimationFile(skeletonData, "data/skeleton-YourSpineCreatedAnimation.json")

I have only created 1 “AnimationObject” and keep changing out my different animations it plays. Since there are very few Spine examples, I had to create my own methods to handle changing animations and well, pretty much everything else. Nate @ Spine had to hand hold me through a few parts I didn’t understand. The thread is on their board, a couple of good insights there.

I built a table that holds all the animations and just grab them as I need them.

The animations update every frame with the Runtime listener you’ll see in the example main.lua.

Realize the example doesn’t even come close to displaying what can be done programmically
with the Spine runtimes which are modules.

So bascially, I only “load” the json animations built in the Spine editor into the “AnimationObject” which are played through the Runtime listener. Building the animations is the easy part from my experience due to the lack of lua examples.

The next thing I knew, I had a fully animated iBot jumping all over my display screen replacing the boring static .png. Oh…he has a cannon now that aims with the user’s drag to fire the electro orbs.

Yeah, you can dynamically alter the animations or poses you make in Spine with “touch” events…it’s really cool.

Spine ROCKS!

Nail

[import]uid: 106779 topic_id: 36022 reply_id: 143156[/import]

I guess what you basicly need to know is that the runtime module you should require in order to import the json files spine exports comes with spine when you purchase it. So you can’t import the animations from spine with the trial version.
I agree spine is very cool. [import]uid: 13632 topic_id: 36022 reply_id: 143158[/import]

ojnab, you are correct. I didn’t even realize that. That’s a very important part of the equation, the Runtime modules and obviously the example main.lua. eeek!

I only tried the trial editor for a couple of minutes and instantly saw it would work for me and went ahead and purchased the tool right away, I’ve been buried in it since and didn’t even realize the runtimes aren’t included with the trial. Sorry about that gang.

There’s really not a lot more to the main.lua than what I posted above, just add the listener and a few parameters.

Nail [import]uid: 106779 topic_id: 36022 reply_id: 143161[/import]

@nail
He he. I also bought it after trying it for something like 2 seconds.
I don’t understand why there isn’t anymore fuzz about spine in this forum.
This is the coolest thing that happend for corona based games since corona! [import]uid: 13632 topic_id: 36022 reply_id: 143166[/import]

@ojnab, agreed.

Spine is like a “mini Corona” inside Corona that specializes in graphics. Talk about really “bringing apps to life”! Jaw on floor thinking about the relatively easy possibilities…

Nail [import]uid: 106779 topic_id: 36022 reply_id: 143210[/import]

Thank you guys. Sorry I am sorry for the delay, i am in vacation with limited Internet. I cannot wait to get home and play with Spine (don’t tell my wife:). Thanks Nail, you ibot looks phenomenal!

I will have a million more questions when I get back online!

Mo [import]uid: 100814 topic_id: 36022 reply_id: 143275[/import]

Thanks xnailbender you answered my questions I had about Spine too. I tried it for a few mins and backed them on kickstarter so no Runtimes for me until they release it on GitHub or Saturday when the kickstarter ends. Spine is an amazing tool! [import]uid: 58885 topic_id: 36022 reply_id: 143279[/import]

I just downloaded Spine and followed the tutorial/sample code they have. However, I am looking for a way to play the walk animation only when user press a button (instead of having it in a Runtime/eventFrame situation.

I see xnailbender did a great job controlling spine animations via gestures in his game. Any tips on how to do that?

Thanks a lot,

Alex

Hi Alex,

  currently the Spine Corona runtime doesn’t really give a lot of tools to handle animations, you have to basically roll your own tools for it. To run the animation only when a button is down, there are (at least!) two different approaches you can take:

  1. only call animation:apply in the eventframe if the button is down during that event

  2. start/stop your own timer that calls animation:apply when the button is pressed

Hope this helps,

  Matias

Matias,

Thanks for the input but my issue is how to “run” an animation, for example calling:

walkAnimation:apply(skeleton, <here is the issue>, true)

In the original sample, they use a Runtime event that loops the animation time forever, which generates the movement. My (maybe too) basic question is, how to set the animation:apply to play the frames? Any example?

Thanks a lot!

Alex

Hi Alex,

  the second parameter passed to animation:apply is the time in seconds you want the animation to be in - the runtime will interpolate between the frames if your time falls between them.

Thus, you just need to make sure that that number increases between every call to animation:apply, preferably by the amount of seconds passed between the calls - or if it’s paused, by 0 (in which case you don’t need to apply the animation either).

To facilitate this, both the enterframe and timer events contain a property ‘time’ which signifies the number of milliseconds since the application was started, which you can use to keep your own animationtime in sync with the actual time keeping your animations smooth. The Spine sample also shows how to calculate delta (eg. the time between the calls to enterFrame or a timer) which you can then add to your time (when your animation is running) if your animation gets paused every now and then to avoid skipping.

Hope this helps,

  Matias

Thanks again. I think my English was not enough to explain my issue :frowning:

I set the spineBoy as a button, that should play the walk animation when clicked. My question is how to change the “animation time” inside the button listener? I tried a for loop but it did not work.

The sample code only shows an example using the enterFrame event listener, which is not applicable in this case. Do you have a sample code on how to do the walk from a button press?

Hi Alex,

  you shouldn’t try to ‘run’ the animation from inside the event - otherwise nothing else would ever happen as you would never get out of that event. You should probably make the click event change a variable such as ‘animationRunning’ and then in the frameEnter event do something like:

if animationRunning then &nbsp; animationTime = animationTime + delta &nbsp; walkAnimation:apply(skeleton, animationTime, true) &nbsp; skeleton:updateWorldTransform() end &nbsp;

Hope this helps,

  Matias

I just downloaded Spine and followed the tutorial/sample code they have. However, I am looking for a way to play the walk animation only when user press a button (instead of having it in a Runtime/eventFrame situation.

I see xnailbender did a great job controlling spine animations via gestures in his game. Any tips on how to do that?

Thanks a lot,

Alex

Hi Alex,

  currently the Spine Corona runtime doesn’t really give a lot of tools to handle animations, you have to basically roll your own tools for it. To run the animation only when a button is down, there are (at least!) two different approaches you can take:

  1. only call animation:apply in the eventframe if the button is down during that event

  2. start/stop your own timer that calls animation:apply when the button is pressed

Hope this helps,

  Matias

Matias,

Thanks for the input but my issue is how to “run” an animation, for example calling:

walkAnimation:apply(skeleton, <here is the issue>, true)

In the original sample, they use a Runtime event that loops the animation time forever, which generates the movement. My (maybe too) basic question is, how to set the animation:apply to play the frames? Any example?

Thanks a lot!

Alex

Hi Alex,

  the second parameter passed to animation:apply is the time in seconds you want the animation to be in - the runtime will interpolate between the frames if your time falls between them.

Thus, you just need to make sure that that number increases between every call to animation:apply, preferably by the amount of seconds passed between the calls - or if it’s paused, by 0 (in which case you don’t need to apply the animation either).

To facilitate this, both the enterframe and timer events contain a property ‘time’ which signifies the number of milliseconds since the application was started, which you can use to keep your own animationtime in sync with the actual time keeping your animations smooth. The Spine sample also shows how to calculate delta (eg. the time between the calls to enterFrame or a timer) which you can then add to your time (when your animation is running) if your animation gets paused every now and then to avoid skipping.

Hope this helps,

  Matias

Thanks again. I think my English was not enough to explain my issue :frowning:

I set the spineBoy as a button, that should play the walk animation when clicked. My question is how to change the “animation time” inside the button listener? I tried a for loop but it did not work.

The sample code only shows an example using the enterFrame event listener, which is not applicable in this case. Do you have a sample code on how to do the walk from a button press?