Jump to content
  • Advertisement
Sign in to follow this  

How can I save this info properly so I can take it apart later (2D animation tool)

This topic is 4773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay so I am wrighting my own tool for animating sprites. The user selects pictures, states how long they will show, their x/y cords, x/y displacements ect. Then it saves this info into a file, a binary file. Then in my game engine it loads this file disects the info and assigns them to the proper variables. Heres an example of what my info would be if I had 2 sprites, couple animations each, and a few frames each.
Sprite1: Animation1: Pic1: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic2: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic3: x: y: x-displacement: y-displacement: HowLongPicShown
         Animation2: Pic1: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic2: x: y: x-displacement: y-displacement: HowLongPicShown
Sprite2: Animation1: Pic1: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic2: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic3: x: y: x-displacement: y-displacement: HowLongPicShown
         Animation2: Pic1: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic2: x: y: x-displacement: y-displacement: HowLongPicShown
         Animation3: Pic1: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic2: x: y: x-displacement: y-displacement: HowLongPicShown
                     Pic3: x: y: x-displacement: y-displacement: HowLongPicShown
Well I hope that shows up how I typed it, with the indents so its easier to read. So how could I save this into one file in my sprite animator tool, and secondly how could I open that file and assign that info to variables in my game engine. [edit] Washu: Code tags work wonders :P

Share this post


Link to post
Share on other sites
Advertisement
I think a problem like that more or less needs a language-specific answer, and I don't know the first thing about the language you are using so can't help.

In C you would save it to a file using the fprintf function or similar, which outputs formatted text to a file, then read it back in using the equivalent functions. I'd recommend trying to find some kind of XML parsing library though, that would be a much neater way of doing it.


<sprite name="sprite1">
<animation name="animation1">
<pic name="Pic1" xpos="..." ypos="..." .... />
<pic name="Pic2" ... />
</animation>
</sprite>
etc.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!