2D Animation Format??

Started by
1 comment, last by imDivineLight 19 years, 9 months ago
I am making my own animation format for 2D graphics, i need some help to avoid pitfalls in advance, i have chosen XML for saving it. now here's my approach:

// The XML Prototype
<Animation Sets="2">
    <TileSet Bitmap="Anim.bmp" TileWidth="64" TileHeight="64"/>
    <Set1 Name="Walk" FrameDelay="100" Frames="4" Frame0="0,0" Frame1="0,1" Frame2="0,2" Frame3="0,3" />
    <Set2 Name="Stand" FrameDelay="200" Frames="1" Frame0="0,4" />
</Animation>

// The implementation prototype
// Create two animated 2d objects
cAnimation Toad, Toad2;
// Load tileset and animation info from file
Toad.Load( "Anim.xml" );
// Animation info is loaded already just acquire pointer to it to save 
// memory
Toad2.GetAnimInfo( &Toad );
// Allow easy functions to play them
if ( KEYDOWN(LEFT) )
	Toad.Play( "WalkLeft", mfElapsedTimeSincelastFrame );

Toad2.Play( "Jump", mfElapsedTimeSincelastFrame );
here is how i plan to do these things is it ok to go with this approach?
::- Hear the beauty of silence -::
Advertisement
hello there,

we use xml to store our animation description too,
the only thing we do differently, is when an xml document is loaded,
it is cached, and the next time it is loaded it simply returnes the cached version, we dont expose the 'cAnimation' class to the developer in our engine, instead it is handled internaly using the xml file as an alias.

=)

//load up me.xml
sprite1.Load("data/me.xml");
//internaly use existingly parsed and cachced xml data
sprite2.Load("data/me.xml");


as for playing the animation, we also have a boolean flag we pass, that lets us specify not to restart an animation if it is already playing, helpfull at times=)

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

So do you keep a static list of all loaded animations??
or you do it another way??
Moreover i was thinking about hiding my XMLs in some way, so i stop the kids from making funny alterations to my animations and other game XML files.
::- Hear the beauty of silence -::

This topic is closed to new replies.

Advertisement