I totally spaced and forgot to mention! I just launched a kickstarter for something Binary Solo is doing. It’s called Indie Van Game Jam and it features myself and Zeb “The Wedding Party” West! We travel around in a van while making games and interviewing independent game developers.
It’s going to be a lot of fun to make, regardless of whether it gets funded or not! Watch our kickstarter video!
Seriously, though, it really is that easy to generate a Sprite or TextureAtlas with TexturePacker. You create a folder of trimmed images for each item to be put in atlas. When I say trimmed, I mean that the image should be sized exactly how you want it to appear. A trick some people use is to work in layers with Photoshop, then simply export layer by layer. If you have any extra transparency in the image that you do not want, the atlas itself will remove it, but will use magic in the metadata file you use to describe it. In the cocos2d plist file, you will see a large sourceSize. You do not have to learn the hard way that this will cause you positioning and scaling issues if you forget.
So you drag that folder into the panel on the right. Choose cocos2d plist when exporting the file. (Even though there is a Unity format!) Click Publish. If you were using cocos2d, you’d be done by now! Unfortunately, you are not, so you have to take one whole additional step. Rename the .plist file to a .xml file. Now drop those into your project in Unity!
Now that you have your files in Unity, make sure they import correctly. Especially check if your file is 2048 in either dimension (but not bigger because that would be bad).
Okay, file is there, you are ready to set it up. Grab an OTSpriteAtlasCocos2D from the Assets > Orthello > Objects > Sprites > SpriteAtlas folder and drop it into the scene. (A great place to put it would be OT > Containers in the Hierarchy!) If you select the texture that we created earlier along with the Atlas Data File, you should watch in amazement as the Atlas Data gets filled!
Almost done! To reference those frames, we need to make an object. Let’s set up an Animation located in Assets > Orthello > Objects > Sprites. Give that prefab a drag into the Hierarchy at OT > Animations. Fill in the Framesets portion with Size being the number of animations you have in the texture. For each Frameset, you can either manually size and type the Frame Names in each Frameset, or you can use the Frame Name Mask to grab every frame that starts with whatever you type. (Warning: It quickly switches focus to one of the elements, be aware.)
Now you’re all set to create an AnimatingSprite in code or set one up in the scene. Go you!
Sometimes, when people besides myself program, there are problems in an application. Okay, I’m being a little facetious. Sometimes, even when I program, there will be errors during the lifetime of an application. This is to be expected if you are a developer. We know that nothing is perfect. We know that there are all different types of hardware problems we couldn’t account for. People don’t use our programs like we thought they would, and end-users don’t know how their software works under the hood. If one click didn’t work, try two. Try clicking harder. Try closing the program while it’s doing important work. They try everything.
This is why it is necessary to have useful error messages when the program encounters a problem, whether it be bad data, an odd code path, or misuse on the part of the user. (And it needs to handle it properly.)
Read more ›