How Spine works with corona?

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   animationTime = animationTime + delta   walkAnimation:apply(skeleton, animationTime, true)   skeleton:updateWorldTransform() end  

Hope this helps,

  Matias

Can you guys tell me please if scaling body parts of a character is working for Corona using Spine? I sometime read something about Corona having problems with the Spine scale functions. Is this true?

I want to create some “Flash” like character animations with scaled body parts… for example a breathing character who’s torso is getting big and small in a scaled loop.

Thank you for your help!

Daniela

D -

I haven’t scaled individual body parts in my animations, so I don’t know for sure.  I do scale my entire animation though, so don’t think there would be a problem.

I like the idea of a “breathing” chest, cool!

Let us know how is works out for you.

Nail

There’s indeed a problem with Corona and Spine when stuff gets scaled.

In particular, if an image is attached to a bone in an angle that’s not one of the cardinal directions (0, 90, 180, 270) and the bone is scaled, the result becomes impossible to draw in Corona, as Corona can only draw textures to rectangles and not quads (see here for an example of what should happen).  The new Graphics engine that’s been teased for a while should enable this, but I’m not sure when it will be released.

So, for now make sure your images are aligned to the bones and there should be no problems!

Thx for your answers. I have one other questions: Is it possible to create (for example) a character with bodyparts, animate it (rotate the hands and legs, head and so on) and then take this animation and do other transformations on the whole animating character, like for example a rotation, while the hands and bodyparts are still moving… or other transformations on the whole character?

Thx for your help!

Daniela

I haven’t done this but I think the way to do it is something like:

animation.apply(skeleton, delta) -- Do rotations and move limbs. skeleton:updateWorldTransform()

By changing the skeleton between the animation call and the updateWorldTransform call you can make individual bones behave independently of the animation without effecting the rest of the animation.

Yes, it sure is. When you create a new Spine character in Corona, it will either create it’s own displaygroup (skeleton.group) that you can then scale and transform freely. You can also pass in your own displaygroup if you want (in skeleton.new, see spine.lua), wherein the spine object will be created.

Basically, what you’d do is:

skeleton = spine.Skeleton.new(skeletonData)
skeleton.group.rotation = 125

Looking at updateworldtransform code (spine.lua around line 112), it certainly doesnt seem like you can. animation.apply sets the correct values for all the bones and updateworldtransform sets the displayobjects values to match those, overriding anything that already was there.

I think I misunderstood the question. I thought it was about rotating limbs of the skeleton to some new position like following a touch event while still animating.

If you call animation.apply then change the skeleton, updateWorldTransform() sets the display objects values to the overridden skeletons values.

Thx again!

One more question: Is it possible to change graphics inside the animation? In the editor we have the two sections “setup” and “animate”. In “setup” we can change the graphics… for example “eyes_open” to “eyes_closed”. In “animate”  we can’t do this changes and we can’t use keyframes for setting new graphics, like “eyes_closed”.

Is it possible to somehow make the characters eyes blink while walking?

Daniela

Sure, set a timeline position then change the visible image in the tree for a slot. A yellow dot will appear in the key column for the slot, indicating an un-keyed change has been made. Click the dot and it will change to red to indicate a key has been set.

Can you guys tell me please if scaling body parts of a character is working for Corona using Spine? I sometime read something about Corona having problems with the Spine scale functions. Is this true?

I want to create some “Flash” like character animations with scaled body parts… for example a breathing character who’s torso is getting big and small in a scaled loop.

Thank you for your help!

Daniela

D -

I haven’t scaled individual body parts in my animations, so I don’t know for sure.  I do scale my entire animation though, so don’t think there would be a problem.

I like the idea of a “breathing” chest, cool!

Let us know how is works out for you.

Nail

There’s indeed a problem with Corona and Spine when stuff gets scaled.

In particular, if an image is attached to a bone in an angle that’s not one of the cardinal directions (0, 90, 180, 270) and the bone is scaled, the result becomes impossible to draw in Corona, as Corona can only draw textures to rectangles and not quads (see here for an example of what should happen).  The new Graphics engine that’s been teased for a while should enable this, but I’m not sure when it will be released.

So, for now make sure your images are aligned to the bones and there should be no problems!

Thx for your answers. I have one other questions: Is it possible to create (for example) a character with bodyparts, animate it (rotate the hands and legs, head and so on) and then take this animation and do other transformations on the whole animating character, like for example a rotation, while the hands and bodyparts are still moving… or other transformations on the whole character?

Thx for your help!

Daniela

I haven’t done this but I think the way to do it is something like:

animation.apply(skeleton, delta) -- Do rotations and move limbs. skeleton:updateWorldTransform()

By changing the skeleton between the animation call and the updateWorldTransform call you can make individual bones behave independently of the animation without effecting the rest of the animation.

Yes, it sure is. When you create a new Spine character in Corona, it will either create it’s own displaygroup (skeleton.group) that you can then scale and transform freely. You can also pass in your own displaygroup if you want (in skeleton.new, see spine.lua), wherein the spine object will be created.

Basically, what you’d do is:

skeleton = spine.Skeleton.new(skeletonData)
skeleton.group.rotation = 125

Looking at updateworldtransform code (spine.lua around line 112), it certainly doesnt seem like you can. animation.apply sets the correct values for all the bones and updateworldtransform sets the displayobjects values to match those, overriding anything that already was there.

I think I misunderstood the question. I thought it was about rotating limbs of the skeleton to some new position like following a touch event while still animating.

If you call animation.apply then change the skeleton, updateWorldTransform() sets the display objects values to the overridden skeletons values.

Thx again!

One more question: Is it possible to change graphics inside the animation? In the editor we have the two sections “setup” and “animate”. In “setup” we can change the graphics… for example “eyes_open” to “eyes_closed”. In “animate”  we can’t do this changes and we can’t use keyframes for setting new graphics, like “eyes_closed”.

Is it possible to somehow make the characters eyes blink while walking?

Daniela