Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Example of Spine runtime for Codea uploaded to Codea Community

edited January 2014 in Code Sharing Posts: 580

I don't know how much interest there is here in the Spine skeletal animation tool (, but from what I've seen it's pretty sweet. I decided to take a crack at hacking the official Spine runtime for Love, and it turns out it really wasn't so difficult to get something up and running.

You can grab the project from Codea Community, and you'll need to grab the images from and put them in your Documents folder (you can also put them in your Dropbox if you'd rather, see the comments in the code).

I'm probably not going to mess with this too much for a bit, but I may revisit it in a couple of weeks. I may take a crack at making it a little more Codea friendly. Plus I need to learn how to use the tool, it looks pretty awesome.


  • edited January 2014 Posts: 113

    The Spine tool does indeed look awesome. I'm sure having the ability to import its animations will be really useful in Codea, so thanks for sharing the code, @toadkick.

    I'm surprised how many assistive tools there are for aspiring game developers. With the likes of this, Cider and the Juice libraries, not to mention Codea itself, there are many ways to get started and learn how things work.

  • Posts: 2,054

    Looks really cool. Might check out your port soon I have a possible use for animations like this.

  • That is very nice. and runs quite smoothly on my Ipad 2. I wonder how it scales for more characters on screen.

  • edited January 2014 Posts: 580

    @spacemonkey: I haven't attempted any profiling yet, but if I had to guess I'd say that you'd probably be able to have quite a few characters animating like this. I've seen some areas that might benefit from some micro-optimization (using local references instead of globals, etc), but I don't think that will make that much of a difference. Also, because of the use of parasitic inheritance, object creation is more expensive than it would be using Codea's classes; on the other hand, it should be at least slightly faster to actually use the objects after they are created. I think memory usage might be the more pressing concern (again because of parasitic inheritance), but I'll have to do some experimenting and profiling to find out. If any one else happens to do any benchmarking of their own, please let us know which device you were using and what your results were!

  • BriarfoxBriarfox Mod
    Posts: 1,542

    @toadkick thank you. This is awesome.

  • Even memory management may not be such an issue when you compare it to the traditional approach of big sprite sheets for frame based animation

  • Posts: 580

    @spacemonkey: That is a very good point :)

  • Posts: 666

    This is excellent! I was looking for such a tool! How hard was it to port the code to work in Codea?

  • edited January 2014 Posts: 580

    @aciolino: it wasn't bad at all, it took me about 2 hours. Half of the work was modifying the runtime to put everything directly in the spine namespace, instead of using the require() function, so that it would work better with Codea's tabs.

    @matkatmusic: Yeah that was actually my starting point. The thing that was missing there was rendering code, so I borrowed the rendering code from the Love2D runtime,, (which is also built on the generic Lua runtime you linked to) and modified that to work with Codea, which was the other half of the work.

  • Posts: 666

    This looks great. Too bad they crippled save. It would be. Great tool if you could demo save for like 10 bones and 3 animations.

  • edited January 2014 Posts: 580

    After seeing this running in Codea, I went ahead and bought the essential version (on sale still for $60). My initial impression is that I quite like it. Your mileage may vary, I am not exactly an artist (much less an animator). Even basic usage of this tool combined with the spine runtime opens up a lot of options when it comes to procedural animations, and even with my meager art skills there's a lot there to play with. As far as usability, the tool strikes me as incredibly polished; there was a lot of love put into it.

    The fact that it works on Mac, Windows, and Linux (the license allows for installation on 2 machines, for 1 user) is awesome. Also, as far as I can tell, there really isn't another tool out there like this for 2D animation with a focus on games...especially not one as widely supported as this (seriously...they provide a ridiculous amount of runtimes and their source, and there are tons of unofficial runtimes). It was pretty simple to get this running in Codea, but it was even easier in Love2D.

    On the other hand:

    If you are an animator, you will probably really, really desire the "pro" features. Those include "ghosting" (a.k.a. onion skinning), "Auto Key" (ugh), and various other "advanced" (though some are a lot more like convenience) features. Unfortunately, those come with a much steeper price tag (normally $299, on sale right now for $250). Unfortunately it seems like it would be hard to tempt an animator to take a serious stab at the trial, when they'd essentially be throwing that time away since they can't save any of their work. So yeah, I totally agree with you on that point @aciolino, it's really lame that you can't save at all with the trial. I would definitely be interesting in an actual animator's impressions of this tool.

    As an aside, I think some of these "pro" "features" seem kind of mean (namely, Auto Key and Ghosting). It goes without saying that the developers deserve to be paid for their work, but it almost feels like they are intentionally making the workflow worse if you aren't willing to cough up the extra dough. I think the upcoming deformable polygon features alone would justify the more expensive price tag, I don't see why some of these had to be excluded from the "essential" version.

    To conclude: as a programmer, with next to no art skills, I am willing to spend $60-75 on the tool, and find it to be worth it if you are serious about using skeletal animations in your games in any form. However, I cannot give an honest impression as an animator, so unfortunately I cannot say whether it is worth it at any price :/

  • Posts: 666

    That is an excellent overview. I'm able to drop the 60 bucks on the tool as it looks like EXACTLY what I wanted later to IK and bones (I've written about those in the past), so it looks pretty exciting.

    I'm thinking that rendering 15 or 20 characters and checking the frame rate is the only curious it't I have left on this thing.

    I agree that overall it looks fantastic.

  • Posts: 2,054

    Does this project require having Spine for your computer, or can it create animations?

  • Posts: 666

    Lua runtime runs animations in you app!

  • edited January 2014 Posts: 580

    @JakAttak: Spine is a tool for your computer to create sprite-based skeletal animations. This project (Spine-Codea) is an example of using the runtime library that can play the animations that are created with Spine.

  • Posts: 2,054

    @toadkick, ah now I understand. I have downloaded the trial of spine to give this a try and see if I might be interested in purchasing spine. It looks to be a very useful program

  • Posts: 2,054

    Just loaded this from CC and ran it, this is amazing! I have a few questions though:

    1) How do I import my own animations?

    2) How processor-intensive is this? Is it plausible to have multiple animations like this running as part of a game?

  • BriarfoxBriarfox Mod
    Posts: 1,542

    You will need to buy the Spline software for PC or Mac.

  • Posts: 1,595

    @Toadkick it looks like my dream tool! Except I'd prefer to make all the sprites using the skeletal system then copy each one on to a sprite sheet, but you can't save images! This might be possible with the trial version though if I screenshot each sprite on to a sprite sheet then discard the background colour.. free skeletal image editor ;)

  • edited January 2014 Posts: 580

    @JakAttak: 1) as @Briarfox said, the paid version of the tool can export a JSON data file that you can use with the runtime. 2) I've not done any performance testing, but yes, I think it probably performs well enough to at least have several skeletons animating at once.

    @Luatee: The paid version of the tool can generate sprite sheets for you (you could also use TexturePacker), however there is currently no support in the Spine-Lua runtime for loading them; you'd need to write the code to handle that, which actually shouldn't be too hard.

  • Posts: 2,054

    I have the Spine PC and I'm just wondering what I have to change to get a new animation with a different images to play

  • edited January 2014 Posts: 580

    @JakAttack: Ah, okay. So this is a bit rough, hopefully features in the upcoming version(s) of Codea will make general asset loading easier:/

    So, what I do in the Spine-Codea demo is basically take the json file that Spine outputs, wrap it with the long string operators ([[ ]]), and assign it to a global variable in a tab with the same name (see spineboy_json in the in the Spine-Codea demo). You can then use that to create and load a spine.SkeletonJson, which you can then in turn use to create a spine.Skeleton.

    As for the images, by default skeletons use utils.getImage() for getting the image location; right now, it's set to load from Documents. This can either be overridden for all skeletons by modifying/overriding utils.getImage() to load from somewhere else (like your Dropbox folder for example), -or- you can monkey patch the skeleton's getImage() function to modify the loading just for that skeleton (if you look in the Spine-Codea demo, there's a commented out bit of code in main that does just that).

    EDIT: Also, if you haven't already, I highly recommend reading the documentation on using the spine runtimes ( It is very informative, and gives a lot of great examples of what can be done with Spine.

  • Posts: 2,054

    @toadkick, thank you. I will look into it.

  • Posts: 666

    As an FYI, I did a simple sunflower animation where the images were pretty big., and with 10 skeletons in a table renderer, I get about 45 fps. 5-7 skeletons gave around 50 fps. 30 skeletons were near 30 fps. 50 were 15, 100 was 9 fps.

    Image Size and skeleton scale didn't matter.

  • Posts: 580

    Thanks @aciolino that's good information :) Out of curiosity, which ipad do you have?

  • Posts: 666


  • Posts: 505

    I'm very interested in testing this. But the runtime seems so be not complete. TextureAtlas'es is not even included. It seems like SkeletonData gets loaded and played but I see no images or anything on screen. Could anyone assist me?

    (Sorry for bumping such an old thread.)

Sign In or Register to comment.