e2d::graphics::AnimationMap Class Reference

Inheritance diagram for e2d::graphics::AnimationMap:


List of all members.

Detailed Description

Every animation is composed of a sequence of images, called "frames". This class contains a map of animations, being each animation a list of frames and their duration (in milliseconds). Animations shall be loaded from a xml tag contained in a tilemap, sprite, or other kind of xml file. The tag must be in the following format:

    <animation id="1" duration="500" name="jump">
      <frame gid="0" />
      <frame gid="1" />
      <frame gid="2" duration="100"/>

The xml may contain any number of <animation> tags, they will be stored in the map and can be recovered by their "id" attribute (id must always be an integer). "Duration" is a value in milliseconds that means the time elapsed in every frame of this animation, unless overwritten by another duration in the "frame" tag. The "name" attribute is optional, Easy2D won't do anything with it, but it helps you not getting lost in the middle of all these animations ;). In the frame tag, "gid" is the index of the frame (for example, if you use it in conjunction with an Tileset, gid should be a tile index).

If you want, you may assign these values by hand, because AnimationMap is a child of std::map, defined as follows:

  class AnimationMap : public std::map< unsigned int, std::list<AnimationFrame> >

To use these values, it is desireable to assign this animation map to an instance of Animation, who has methods to control animation sequences.

This class also is a child of Resource, so it may be stored in ResourceMap if you want to share it among other objects.

If you load an animation map from a xml file, it will be automatically added to (or recovered from) the ResourceMap.

Public Member Functions

void Load (xml_node<> *node)
 Loads animation.

Member Function Documentation

void e2d::graphics::AnimationMap::Load ( xml_node<> *  node  ) 

Fills the map with information contained in the already parsed xml tag passed as parameter.

node parsed <animations> tag (xml_node is part of RapidXML).
e2d::core::Exception if map was already loaded (this->size() > 0) or xml_node is not an <animations> tag.

Generated on Tue Dec 8 10:32:45 2009 for Easy2D by  doxygen 1.5.6