I have been designing a sprite maker for my 2D games. The idea is that my sprite maker would produce a sprite map and an XML file describing the sprite map. I would also produce a Sprite class & DLL in C# that would be able to read the XML file and handle all sprite animations for you.
For the purpose of this project, I have defined the following:
- A
Spriteis the collection ofSequencesthat represent aGame Element - A
Game Elementis a visual element in the game-world - A
Sequenceis a collection of orderedFrames - A
Frameis a rectangular section of an image
That is to say that menu items, HUDs, buttons, text, loading screens, all of that is not a Sprite because they do not exist in the game-world.
Also, each Sequence has a unique combination of Set, Animation, and Orientation where:
- A
Setrepresents the set of the sprite to use. This can be used for a second, complete set ofSequencesfor the sprite. Examples are: (full health, half health, and almost dead) or (sword, vs spear). - An
Animationrepresents an action that the sprite is doing. Examples are: Idle, Walking, and Jumping - A
Orientationrepresents the direction the sprite is facing. Examples are: (left and right) or (0, 45, 90, 135, 180, 225, 270, and 315 degrees)
Any of the above can be left as “Default” if they aren’t useful for your application. Every frame can be accessed by using a 4-dimensional array like so:
frame[set][animation][orientation][frame#]
Where the frame# indicates the progress through the Sequence. When the Animation changes, the frame counter restarts at 0. When the Set or Orientation changes, the Animation and frame counters do not change, the current animation just continues in the new Set or Orientation. Each Animation indicates which Animation should follow, once completed. For a looping animation, the animation will refer to itself. For a ping-pong animation, there will be a second animation that uses the same set of frames, only in reverse. And for animations continuing on to greater things, they point elsewhere. Whenever an animation completes, either a flag will be set to indicate this, or an event will get fired to allow the game to take any required actions (like start moving after standing up).
In my editor, I am building a few import methods to import from individual files, existing sprite sheets, and even 3D models. I have already built something that will load 2D individual files from Reiner’s Tilesets, but am currently focusing on building the 3D->2D importer. I should have this project on SourceForge before too long.