I will talk about my own experiences with the software, about what I was able to do and of course about integrating it with XNA.
By Catalin Zima
Over the last week or so, I had the chance to play around with Toon Boom Studio, which is a software for creating graphics and animations using a large range of techniques. I won't start to enumerate the whole feature set, which you can see in the video tour, or the detailed features list. However, I will talk about my own experiences with the software, about what I was able to do and of course about integrating it with XNA.
The first thing that needs to be said is the Toon Boom Studio is not just a software for drawing images, but has features designed specifically for creating animations, which lack in other drawing packages such as Photoshop, GIMP, or Paint.Net. So because they serve different purposes, you can't directly compare Toon Boom Studio with these tools.
The interface is nice and after a few hours of fooling around, and reading some tutorials, you get the hang of it and start being productive. After some experiments that are not really worthy of being shown, my first serious attempt was to try and draw the following image in Toon Boom Studio.
My favorite feature of Toon Boom Studio is the ability to take an image, and put it on the Static Light Table (semi-transparent background) so you can draw over it using the Toon Boom Studio drawing primitives. In less than an hour, I was able to create something similar to the source cat image, but all done with vector graphics.
Now it was time to animate it, and the technique that seemed easiest to me was the cut-out animation technique. In this technique, you can isolate areas of the image, creating body parts, and link them together to create a hierarchy of part, just like you would do a skeleton in a 3D modeling animation. Then, in order to animate, you simply set the keyframes with different position and rotation values for each body part, and Toon Boom Studio will take care of interpolating and animating your scene.
Since this was also a learning exercise, it took several hours, but in the end, I had the following animation: Considering it's my first jab at 2D animation, I was very satisfied with the results.
The whole cat drawing was based on someone else's art as a source image, so I felt like a little cheater This is why today I found one of my older “concept drawings” (if you can name it so), and decided to try and make the character in Toon Boom Studio.
As you can see, my art skills are not something to be proud of. However, about 2 hours later, the result looked much better.
I'm sure a talented artist would have done this much faster, and with much better results, but from my point of view, it is a great progress. Some things I did to help me out:
While definitely not an elegant solution, it did it's job, and I was quickly able to obtain the following image (click for larger size):
The third option, which is the recommended one for a larger project, is to use a more complex program for creating sprite-sheets. You can either create one yourself, based on certain file formats you want to use internally, or around certain restrictions you want to impose on your engine; or you can use an existing one, such as Ziggyware's Sprite Sheet Creator (no longer available online). Note that if you go for this option, you'll have to follow certain conventions in your runtime code, imposed by your program used for creating the sprite-sheets.
That being said, we now have a sprite sheet with all the frames of the walking cat animation, and are ready to load this in XNA.
After creating a new XNA project, I read through Nick's article about Sprite Sheet Animations (no longer available online), and created the following class to hold all information needed for animations. For a detailed explanation, go ahead and read Nick's article.
Next, I created a class for the cat, holding a few members we need for the animation.
Nothing really special here… Maybe except the isMirrored variable. We use this because our image for the cat shows it facing left. So when we want it to move towards the right, rather than creating a separate sprite with the cat facing right, we mirror the existing sprite. Of course, you can't always use this trick (or a right-handed character suddenly becomes left-handed), but there are many cases when this trick is enough.
The constructor is straightforward, with some hard-coded values tweaked until I was satisfied with how things looked.
For movement, input from both keyboard and gamepad is analyzed, and the velocity's value is updated.
In the Update function, we first look which way the cat is facing, and update the value of isMirrored. Then, if the cat is moving, we update the animation and position on the screen.
Finally, the Draw function takes as a parameter the active spriteBatch, and draws the current animation frame using it. Here we can see how to mirror the sprite using SpriteEffects.FlipHorizontally.
With this class created, using it in our Game class is trivial. Simply load the texture in LoadContent() and create a Cat object, update it's input and internal state in Update() and draw it in Draw().
If you run the game now, you'll be able to move the cat around the screen with the keyboard or the mouse. As you can see, getting an animation from Toon Boom Studio into an XNA game is not difficult at all.
I hope you enjoyed this short post, and if you did, you can download the source for this sample here
Download the project file here: ToonBoomAnimationSample.zip