Sign in to follow this  
imDivineLight

2D Animation Format??

Recommended Posts

imDivineLight    132
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?

Share this post


Link to post
Share on other sites
EDI    3679
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=)

Share this post


Link to post
Share on other sites
imDivineLight    132
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this