maxgribov / Spine

Unofficial Spine runtime Swift library, allows you to play animations created in the Spine app (http://esotericsoftware.com).
MIT License
183 stars 36 forks source link

Question: getting [SKTexture] instead of Action #33

Closed Ideafix0 closed 1 year ago

Ideafix0 commented 4 years ago

Is there a way we can get a list of textures instead of an action when animating an object? Can we add an extension do to that? Thank you

maxgribov commented 4 years ago

can you explain in more detail what you want?

Ideafix0 commented 4 years ago

As a way of animating a character, you have:

if let walkAnimation = character.animation(named: "walk") {

character.run(walkAnimation)

}

I was aiming for something like:

if let walkAnimationFrame : [SKTexture] = character.animationAsTextureVector(named: "walk") { ... } The goal would be to obtain the animation frames as a sequence of textures.

Thank you for your time.

On 29 Apr 2020, at 19:18, Max Gribov notifications@github.com wrote:

can you explain in more detail what you want?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maxgribov/Spine/issues/33#issuecomment-621379857, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNJFAWQCCI7N2Y5E3X67FLRPBVPPANCNFSM4MOBDMKQ.

maxgribov commented 4 years ago

theoretically you can render each frame of animation for your character and get it in the form of texture. But I don't see any practical sense in this. Why do this when you can just play the animation?

and of course I don't plan to add anything like this to the library.. But if you really need it, you can do it yourself... The code is open...

Ideafix0 commented 4 years ago

Animations based on actions have the assumption that the amount of time per frame is constant, which is not always the case. In those cases, there is the need to control the animation rate (which is variable).

On 29 Apr 2020, at 23:43, Max Gribov notifications@github.com wrote:

theoretically you can render each frame of animation for your character and get it in the form of texture. But I don't see any practical sense in this. Why do this when you can just play the animation?

and of course I don't plan to add anything like this to the library.. But if you really need it, you can do it yourself... The code is open...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maxgribov/Spine/issues/33#issuecomment-621506348, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNJFAVH7GZWDZHLFPBB2FLRPCUSLANCNFSM4MOBDMKQ.

maxgribov commented 4 years ago

actually, with Spine, you have full control over the time of each animation. You set the keyframes at exactly the right moment...

Ideafix0 commented 4 years ago

You do, but that is before generating the animation. On certain sequences, where animation rate depends on other variables then time (e.x. distance from something) the frame rate control is "on the fly"

maxgribov commented 4 years ago

you can adjust the animation keyframes themselves to fit the timings you need... and it will be much easier than rendering the animation frames as textures...

Ideafix0 commented 4 years ago

The timings may change mid animation (i.e. when the animation is already playing). With an action you can't do that.

maxgribov commented 4 years ago

by the way, you can control the speed of SKAction with property speed

Ideafix0 commented 4 years ago

Depending on the model, it may not be practical.

maxgribov commented 4 years ago

I understand that you have some very specific tasks that go beyond my plans for the development of this library... So I'm sorry, but you'll have to come up with something yourself... Good luck

Ideafix0 commented 4 years ago

Thank you for your time.

On 30 Apr 2020, at 00:01, Max Gribov notifications@github.com wrote:

 I understand that you have some very specific tasks that go beyond my plans for the development of this library... So I'm sorry, but you'll have to come up with something yourself... Good luck

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

maxgribov commented 4 years ago

by the way, you can always render your animations as png images directly from the Spine app. Assemble them into sprite sheets and use them as normal sprite animation.

Ideafix0 commented 4 years ago

That’s what I’m currently doing, and the iOS app payload is too big, even with highly compacted texture atlases. Hence the need to use such a library.

Btw, exactly where in your code are the textures being generated?

On 30 Apr 2020, at 00:05, Max Gribov notifications@github.com wrote:

 by the way, you can always render your animations as png images directly from the Spine app. Assemble them into sprite sheets and use them as normal sprite animation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

maxgribov commented 4 years ago

Btw, exactly where in your code are the textures being generated?

Nowhere. Right now, textures are just loaded from assets.