views:

27

answers:

0

Hi, so I'm trying to store animations in a way that I can reuse them with other images. I want to store the position of each node in a keyframe and use interpolation in the animator to make it look nice and smooth. I would use this for animating everything from walk cycles to weapon animations and etc.. The xml file for a simple ball moving up and down and another one moving back and forth will be something like

(id's are just used to keep track of which sprite to draw)

<animations>
  <animation>
    <name>bounce</name>
    <keyframe>
      <secondsTillNextFrame>2</secondsTillNextFrame>
      <node>
       <id>0</id>
        <xpos>20</xpos>
        <ypos>40</ypos>
      </node>
      <node>
       <id>1</id>
        <xpos>0</xpos>
        <ypos>0</ypos>
      </node>
    </keyframe>
    <keyframe>
      <secondsTillNextFrame>2</secondsTillNextFrame>
      <node>
       <id>0</id>
        <xpos>20</xpos>
        <ypos>0</ypos>
      </node>
      <node>
       <id>1</id>
        <xpos>100</xpos>
        <ypos>0</ypos>
      </node>
    </keyframe>
    <keyframe>
      <secondsTillNextFrame>2</secondsTillNextFrame>
      <node>
       <id>0</id>
        <xpos>20</xpos>
        <ypos>40</ypos>
      </node>
      <node>
       <id>1</id>
        <xpos>0</xpos>
        <ypos>0</ypos>
      </node>
    </keyframe>
  <animation>
</animations>

So by doing animations this way I hope to store just the motions of each object in the sprite, and be able to swap out the images to make different characters with the same movements etc.. Is this the best way to achieve this?